The recommended approach to getting started with Drupal 8 is now via Composer. An official project template has been created for this. We will create our project directly using the template, which is also available on Packagist.
To create a new project based on this template we can run the following Composer command:
composer create-project drupal-composer/drupal-project:8.x-dev my_project --stability dev --no-interaction
This Composer command will pull in the template from Packagist and run a few Drupal specific scripts to prepare our project for installation. The only thing left to do is point our browser to the
web/ directory (since that is where the
index.php file is) and run the installer as usual.
This template comes with a
/web folder that contains, among other things, the main folders of a Drupal installation that are no longer considered part of Drupal core (such as the
index.php file or the modules and themes folders). Additionally, it comes with an
autoload.php file used by Drupal that simply points to the Composer
vendor/ directory, one folder up. So all PHP libraries are now handled from one single place.
composer.json file requires the latest stable Drupal core + some additional helper tools such as Drush and the Drupal Console. Additionally, it adds the Drupal specific Packagist repository from where we can install Drupal contributed modules, themes and profiles (that get automatically installed in the right place).
If we want to add a Drupal contributed module, we need to find it on the Drupal Packagist and require it in our project via Composer:
composer require drupal/ctools
This will add the Ctools module directly to our
web/modules/ directory and update our
The project template also comes with a
.gitignore file that keeps Drupal core and all the contributed packages outside of Git, similar to the regular
vendor/ packages. So based on an updated
composer.json file, we can maintain a smaller Git repository and recreate our project any time. A lot of the benefits of Drush Make have now been incorporated into a Composer flow.
Drupal 8 has come a long way in catching up with other major PHP software. The possibility of fully managing it via Composer, either as a main project or even just as part of a bigger set of applications, is a testament to the community effort that went in.
Daniel Sipos is a Drupal developer who lives in Brussels, Belgium. He works professionally with Drupal but likes to use other PHP frameworks and technologies as well. He runs webomelette.com, a Drupal blog where he writes articles and tutorials about Drupal development, theming and site building.
Your First Year in Code
Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers
Jump Start Git, 2nd Edition