Yet another web developer blog


Launch VS Code IDE inside a Docker container


  • You don’t even need to install the language package (PHP, Node.js, Go, etc) and all other tools locally on your host system, you only need to have the VS Code app (or even Free/Libre Open Source VS Codium app).
  • You'll got a native app experience with local graphical interface, but all operations are performed inside the container.
  • You'll use for development the same versions of language compiler (php or other) and tools (composer, phpcs and others) as installed in th

How to create a custom Drupal Entity Type in a single PHP file

Most of instructions about creating a new custom Drupal Entity Type describes that you need to create a lot of files: routing, links, form, list builder, interfaces, etc.

But if you need to create just a simple custom Content Entity Type for your own needs and with mostly default functionality, you can simply describe it in a one PHP file, with reuse of Drupal Core classes for all other functionality (User Interface, Permissions, List Builder, etc)!

Here is the example:


Quick way to create an own patch for composer package of Drupal module and other projects

Very often we need to quickly change something in source files of composer package (for example some Drupal module), and generate a patch with those changes.

This can be done via those steps, using drupal/search_api_solr composer package as example :

How to eval PHP code via drush without escaping quotes routine

Very often there is a need to execute via drush eval command the PHP code with both single and double quotes, something like this:

echo "Hello, '$username'!"; 

This can be quickly done without manually adding slashes to each quote in PHP code via this bash trick:

PHP=`cat <<'EOF'
echo "Hello, '$username'!"; 
EOF`; drush ev "$PHP"

Instead of single line of PHP code, you can insert long multi-line part of code, without carrying about escaping quotes.


How to view and revert installed schema version of module in Drupal 8, 9

After executing hook_update_N functions, Drupal stores last version of installed updates in his key-value storage, if update function executed without exceptions.

You can simply lookup installed version via command-line drush command:

drush ev "var_dump(drupal_get_installed_schema_version('my_module'))"

Sometimes you may need revert version to previous, for re-apply updates, or repeat updates, if they previously executed with problems.

You can set previous version of Drupal module schema version via this cli drush command: