I'm a full stack web developer and here is the place, where I collect useful information about developing cool web services and sites.
My favorite technologies are:
- PHP: Drupal Content Management Framework, Symfony Framework.
- System administration & DevOps: Kubernetes, Docker, Debian/Ubuntu Linux, SaltStack.
The Drupal 10 release, as described, is mostly about deprecations and removing old code. So it's pretty easy to port your modules to Drupal 10, they said!
But actually - not!
Together with deprecations, we have some libraries updated to the new major versions too, and this can bring you little unexpected surprises when you try to make your module compatible with both Drupal 9 and 10 versions together.
- 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
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:
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 :
Common systemd usage is to manage global linux services, that can be created/modified only with root/sudo credentials.
But systemd have the great user mode, that allow to create and control any services without sudo permissions, that runs as user owner, we simply need to add the `--user` argument.
For allow to start user services on system boot, you must one-time launch the command for needed user:
sudo loginctl enable-linger LOGIN
DO $$ DECLARE r RECORD; BEGIN FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE'; END LOOP; END $$;
This query will delete all available tables for current user and schema, without needs to have SCHEMA privileges.
The most popular solution via:
DROP SCHEMA public CASCADE; CREATE SCHEMA public;
Often shows the error, because of missing owner permissions or other restrictions:
Very often there is a need to execute via
drush eval command the PHP code with both single and double quotes, something like this:
<?php 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.
Here are steps for quick configure fresh-installed Ubuntu Server to manage Nginx Virtualhosts with PHP (using PHP-FPM) and Proxy to Node.JS apps.
Here is bash commands to quickly install salt-minion to Ubuntu / Debian systems:
MASTER=salt.SERVER.COM BRAND=PROJECTNAME HOSTNAME=hostname.SERVER.COM hostnamectl set-hostname $HOSTNAME cd /tmp && wget -O - https://bootstrap.saltproject.io | bash && rm ./bootstrap-salt.log echo "master: $MASTER " > /etc/salt/minion.d/$BRAND.conf echo "$HOSTNAME" > /etc/salt/minion_id service salt-minion restart
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: