Home - pierregermain/MyDrupal GitHub Wiki

MyDrupal Wiki

Must Have Wikis

ddev

Quick D10 quick start

When installing ddev with drupal, if you get 403 error have a look at your docroot configuration:

$cat .ddev/config.yaml 
(...)
docroot: web
(...)

Commands once installed

ddev drush uli
ddev start #to spin up the project.
ddev launch #to open your project in a browser.
ddev describe #to get project details
ddev help #to investigate commands.
ddev xdebug off|on
ddev snapshot #backup db
ddev stop

More commands Drupal specific information

Attempting to re-run cron while it is already running.

DELETE FROM semaphore WHERE name='cron'

Examples

https://git.drupalcode.org/project/examples

Cache

Sniff code

Using drupal/coder

# 1. Install coder
composer global require drupal/coder

# 2. Check the installed location (needed in next step)
composer global show -P
We assume route "~/.composer/vendor/drupal/coder"

# 3. Add this to your .bashrc (to make `phpcs` and `phpcbf` available)
export PATH="$PATH:$HOME/.composer/vendor/bin"

# 4. Register the Drupal and DrupalPractice Standards
composer global require drupal/coder:^8.3.1
composer global require dealerdirect/phpcodesniffer-composer-installer
phpcs  --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
phpcbf --config-set installed_paths <path-to-code_sniffer>

# 5. Verify
phpcs -i
phpcbf -i

# 6. Have fun
cd /var/html/www/
phpcs --standard=Drupal,DrupalPractice <path-to-module>
# To Fix Errors automatically
phpcbf --standard=Drupal,DrupalPractice <path-to-module>

From IDE

Quickly

docker run -it --rm -v "%cd%":/app -w /app hussainweb/drupal-code-quality:latest phpcs --standard=Drupal,DrupalPractice,DrupalSecure --extensions=php,module,inc,install,test,profile,theme

on your directory you want to check with code sniffer I have Drupal,DrupalPractice

https://github.com/hussainweb/drupal-code-quality/blob/master/README.md

Drupal Check

https://glamanate.com/blog/proper-introduction-drupal-check?utm_source=The+Weekly+Drop&utm_medium=email&utm_campaign=The_Weekly_Drop_Issue_388_05_16_2019

Config - Unable to uninstall

https://karthikeyanmanivasagam.wordpress.com/2018/02/12/unable-to-install-already-exist-in-active-configuration-drupal-8/

Tests

vim ./core/phpunit.xml.dist
./vendor/bin/phpunit -c ./core/phpunit.xml.dist ./modules/custom/

Search through a whole database in Drupal?

(thanks to @juampynr)

drush sql-dump --ordered-dump > dump.sql
egrep -rn 'some regex' dump.sql | cut -c1-100