Malabya quoted very well that “if you don't use git even God cannot help”, and that's quite true for developers. In every project CODE is the backbone for any webapp and often developers waste a lot of time in just struggling to deploy and in version controlling, while GIT can help developers in version controlling without any hassle.
While maintaining a codebase, it is always better to follow these points.
- One Codebase per application/site.
- Tracked by a version control (Git or other version control)
- Many deploys (dev, staging & production)
By using GIT we can have the same codebase and switch branches according to the environment.
Developers can follow one of these approaches for local development,
It so often happens that developers face a lot of problems in setting up their local with ideal environment. The scene as it stands would be that the local environment set-up using Mamp/Xamp/Lamp will have issues with production, or functionality which will be working fine in local machine, but failing when deployed in server(prod/dev/stage)
To avoid this, developers can opt for Docker or Vagrant which helps in replicating the environment as per the requirement and it's easy to customize.
For Vagrant, Developers can go for Drupal VM,Scotch Box,vagrant boxes or can create their own box according to your need. And In Docker Developers can chose between Lando,DDev,Dockersal,Wodby Docker4Drupal.
Developers can use composer to declare and install dependencies via manifest files. Drush make is an age old practice now, and it's time to adopt COMPOSER.
Composer can be used to download Drupal, Drupal contributed projects (modules, themes, etc.) and all of their respective dependencies. These instructions vary based on your approach to managing your Drupal installation.
One of the following approaches can be used for installing a drupal site using composer,
composer create-project drupal-composer/drupal-project:8.x-dev \
example --stability dev --no-interaction
composer require drupal/devel
composer require --dev drupal/devel
composer install --no-dev
composer require cweagans/composer-patches
"2860796: Create a branch of devel compatible with Media in core": "https://www.drupal.org/files/issues/2860796-2.patch"
composer update drupal/devel
composer remove drupal/devel
composer config platform.php 7.1
Deployment becomes a piece of cake when developers use Git. All the configurations stays in one code base and it is recommended to have the config folder outside the Drupal root.
Gitignore plays an important role, and it is better to have the following files/directory in gitignore,
- Core directory
- Contributed modules
- Contributed themes
- Contributed themes
- Contributed profiles
- CSS files
By having these files in gitignore, git diff files will be smaller in size, easier to review and quite impossible to hack the core.
Manual deployments are error prone. This is because it involves humans doing stuff,if developer is lucky he can recover. This job can fall to developers and testers in a development team who would otherwise be spending their time producing the next set of awesome features and improvements to the software.
Developments team can have automation in deployment.Implementing automation needs some basic configuration and then you are all set for the automation deployment. If your using Slack u can use configure to get the notification.
There are lot of Automated Deployment Tools available you can chose them according to your requirement ,some of them listed here,
- AWS CodeDeploy
- Travis CI
These Continuous tools reduce lot of time and makes the deployment process easy.
Deployment Process commands
git pull origin master
drush update-database -y
drush config-import -y