Skip to content

Latest commit

 

History

History
116 lines (91 loc) · 4.97 KB

README.md

File metadata and controls

116 lines (91 loc) · 4.97 KB

Drupal Enterprise Boilerplate

This boilerplate is based on how we are currently working with Drupal at Taller. It may not be suitable for all kinds of projects and still needs lots of decoupling.

Dependencies

How to Use

Installing locally

  • Clone this repository
  • Remove .git folder
  • Now is the moment I suggest you to create your own Git repo and commit the boilerplate code, but it is really up to you
  • Find/replace the following variables (be carefull not to replace in this Readme):
APP_IMAGE_NAME The name of the Docker image for your site
DB_CONTAINER_NAME The name of the Docker container with the database
CI_ACQUIA_DIR The name of the folder to use in CI when deploying to Acquia. Should be different from the repository's name
ACQUIA_GIT_DOMAIN The domain of Acquia's Git repository, not the client domain
ACQUIA_GIT_REPO The Acquia's Git repository of your project
GIT_USER_EMAIL The email to be in the Git config while building in Semaphore and deploying to Acquia
GIT_USER_NAME The name to be in the Git config while building in Semaphore and deploying to Acquia
DRUPAL_SITE_NAME The name of your Drupal site
SERVER_ADMIN Apache server admin
  • Run make (make run-macos to MacOS users)
  • If everything went right, you should be able to access your Drupal site in your localhost
  • You can use the default login and password: admin and 123456
  • Commit Drupal generated files

Coding Standards

PHP Code Sniffer

To mantain the Drupal Coding Standards in our custom code, we use the PHPCS lib with the Coder module.

MacOS users, use the following commands with the sufix -macos, eg: make sniff-macos

To run it against your project, use the following command from Makefile:

make sniff

Some errors in the sniffer can be automatically corrected by running:

make beautify

The remaining errors you'll have to fix by yourself.

Deploying

Currently, the integration and delivery features of this boilerplate assume you are using Semaphore CI for building and hosting the environments in Acquia Cloud. Add more generic scripts that can be used to build in other CI systems or deploy in other servers is one of the many improvements we need to do.

  • In the setup of the Semaphore project, place the following command:
make ci-setup
  • In a job of this project, place the following commands:
git config --global core.autocrlf true
make ci-check
make ci-install
make ci-tests
make ci-install-prod
make ci-deploy
make ci-clean
docker volume ls -qf dangling=true | xargs -r docker volume rm
docker-cache snapshot

Backing up and Restoring local databases

Once your Drupal application has started you can generate a backup of your database anytime you want. You just need to run the following command:

make backup-local-database

The backup will be generated inside of the temp folder with the name backup_local_database_{date}.sql.

And, if you need to restore any database, just place the SQL dump inside of the temp folder with the name local_database.sql and then run the following command:

make restore-local-database

Debugging

If you want to use xdebug for debugging your code you just need to use the command below to enable it (or run the command again to disable):

make xdebug

Note: The command above must be executed within the container, in the folder where the Makefile is located.

You'll receive a message indicating if xdebug is ON or OFF.

Once xdebug is enabled, add breakpoints in the file you want to debug, go to the section Debug in your VSCode (the PHP Debug extension is required) and clicks on the button Start Debugging (this button it's located on the top, beside a Listen for XDebug text). Now, you just have to access the application in your favorite browser and you'll see your VSCode stopping in the breakpoints you added.

To run in Acquia

  • Clone the Acquia repository and add a symlink to docroot named web. This way, the autoload generated by composer will work properly in Acquia servers.

Features

  • Ready to use Drupal installation
  • Drush
  • Drupal Console
  • Node (with NVM)
  • Pre configured Acquia deploy scripts
  • Configured Git Hook to execute the code sniffer on pre-push.
  • cweagans/composer-patches as a dependency, so patch support is already in place

FYI

  • This boilerplate works best with Drupal ^8.5
  • By default, the latest Drupal 8 version is installed
  • You should always commit your composer.lock file