Skip to main content

php, drupal, drush cheatsheet

php, drupal, drush cheatsheet

Find php files with syntax errors:

find ./web/modules/ -name '*.php' -print0 | xargs -0 -n1 php -l

Uninstall, install a theme: 

export theme_name='THEME_NAME'
drush theme:uninstall $theme_name

drush config:set system.theme default $theme_name -y

Run some code with drush:

php -d memory_limit=512M ./vendor/bin/drush -l wco.local php:eval '
  $config = \Drupal::configFactory()->getEditable("core.extension");
  $themes = $config->get("theme") ?: [];
  unset($themes["ish_drupal_theme"]);
  unset($themes["wco_drupal_theme"]);
  $config->set("theme", $themes)->save();
';

Remove a module that doesn't exist:

drush -l your-site.com ev '$config = \Drupal::configFactory()->getEditable("core.extension"); $modules = $config->get("module") ?: []; unset($modules["legacy_drupal_module"]); $config->set("module", $modules)->save();'

.

Please login to post comments: _TODO