On Github GuGuss / slides-drupal-best-practices
Augustin Delaporte
Paris | London | Ann Arbor, MI
Creators of Drupal Commerce
Creators of Platform.sh
The Chinese experience...
Developed multiple Drupal and Drupal Commerce sites
Managed the development of Commerce Kickstart v2
Managed the development of Commerce Guys Marketplace
Used those best practices on my own e-commerce website
It’s easy to maintain a Drupal site
Small websites are built the same way as big websites
Making architectural changes is simple on a Drupal site
Easily save and revert your work
Manage projects with multiple developers
Great flexibility on branching and merging
Audit specific pieces of code
Track down problems that might arise
Powerful *pull request* and *fork* workflow
Drupal without Drush is like life without mobile phones... you know you managed just fine but now you just can't imagine how
Think hard before clicking
Everyone should be able to test in live conditions
Install from scratch at any time
drush feature-revert
drush migrate-import
drush updatedb
Forget about randomly patched modules in the repository
Predictable development workflow
Reusable components across projects
Better tracking of configuration changes
Better integration with automated testing
#!/bin/bash set -xe if [ ! -d marketplace/.git ]; then git clone git@github.com:commerceguys/marketplace.git fi # Go to Marketplace to run backups. run-on-host marketplace_prod@marketplace.commerceguys.com << "END" # Backup files and database (just in case). export DIRDATE=`date '+%Y-%m-%d---%H-%M-%S'` export BACKUPDIR=$HOME/jenkins-backups/marketplace-$DIRDATE mkdir -p $BACKUPDIR cp -RL www $BACKUPDIR/www cd www drush sql-dump > $BACKUPDIR/marketplace-$DIRDATE.sql # End of backup script. END cd marketplace # Fetch the new commits and checkout. git fetch git reset "origin/master" --hard cd .. # Copy to marketplace rsync -a --delete marketplace/ marketplace_prod@marketplace.commerceguys.com:blimp run-on-host marketplace_prod@marketplace.commerceguys.com << "EOF" #!/bin/bash set -xe # Maintenance mode unlink live ln -s marketplace-maintenance live sudo /etc/init.d/php5-fpm restart cd www drush vset maintenance_mode 1 # Stop the Advanced Queue daemon. sudo sv stop advqueue-marketplace # Build website. cd ../blimp export BUILD_ROOT=".." chmod 755 ../www/sites/default ./scripts/build cd ../www # Remove all .txt files find . -name "*.txt" | xargs rm # Rebuild registry drush -y rr --no-cache-clear # Update database. drush -y updatedb --uri=https://marketplace.commerceguys.com # Clear drush caches. drush cc drush # Clear all caches. drush cc all # Revert features. drush -y fra # Rebuild indexes. drush -y sapi-c drush -y sapi-i productdisplay 0 drush -y sapi-i licenses 0 drush -y sapi-i delivery_partner 0 # Go live. drush vset maintenance_mode 0 sudo sv start advqueue-marketplace cd unlink live ln -s www live sudo /etc/init.d/php5-fpm restart EOF