The Drupal bangalore community came together for the July Meetup and it was quite an informative experience, with experts sharing their knowledge on some of the best practices on Drupal.

There were 3 informative sessions, one of which was on â€śImproving your Web Development workflow” by Malabya that showed how developers can improve the quality of Web Development flow by efficiently using git and by setting the local environment with Lando or Docker instead of the traditional way. He also spoke about the importance of using composer for dependency management and deployment.

Codebase

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 web app 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)

image

By using GIT we can have the same codebase and switch branches according to the environment.

Local Web Development Workflow:

Developers can follow one of these approaches for local web development,

  • Mamp/Xamp/Lamp
  • Vagrant/VM
  • Docker

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

How developers can improve the quality of Development workflow by efficiently using git and by setting the local environment with Lando or Docker instead of the traditional way

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.

Composer Workflow

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,

  • drupal-composer/drupal-project
  • hussainweb/drupal-composer-init
  • drupal/drupal
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
"extra": {
  "patches": {
    "drupal/devel": {
      "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 Process

Deployment process becomes a piece of cake when web 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
  • Vendor

By having these files in gitignore, git diff files will be smaller in size, easier to review and quite impossible to hack the core.

Deployment Process Flow:

Manual deployments are error prone. This is because it involves humans doing stuff,if the developer is lucky he can recover. This job can fall to developers and testers in a web development team who would otherwise be spending their time producing the next set of awesome features and improvements to the software.

Web 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 a lot of Automated Deployment Tools available you can choose them according to your requirement, some of them listed here,

  • Jenkins
  • AWS CodeDeploy
  • CircleCI
  • Travis CI
  • BuildBot

These Continuous tools reduce a lot of time and make the deployment process flow easy.

Deployment Process commands

git pull origin master
composer install
drush update-database -y
drush config-import -y
drush cache-rebuild
Contact us

LET'S DISCUSS YOUR IDEAS. 
WE'D LOVE TO HEAR FROM YOU.

CONTACT US