2017 © Pedro Pelรกez
 

composer-plugin drupal-component-scaffold

Scaffolding Composer plugin for Drupal modules and themes.

image

nuvoleweb/drupal-component-scaffold

Scaffolding Composer plugin for Drupal modules and themes.

  • Friday, December 1, 2017
  • by ademarco
  • Repository
  • 2 Watchers
  • 8 Stars
  • 716 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Drupal Component Scaffold

Build Status, (*1)

Drupal Component Scaffold is a Composer plugin that helps Drupal 8 project maintainers enjoy leaner development workflow: working on modules and themes will be like working on any other modern PHP component., (*2)

Once installed the plugin allows to:, (*3)

  • Specify all project's development dependencies in require-dev, like Drupal core, modules, themes or any needed testing libraries (PHPUnit, PHPSpec, Behat, etc.). See an example here.
  • Build a fully functional Drupal site right within the project directory by bundling all listed dependencies by just running composer install.
  • Have the same setup on both local development and continuous integration pipelines. This also leads to cleaner CI configuration files.

The plugin leverages the excellent Drupal Scaffold project and fires only after (and if) its main scaffolding tasks are ran., (*4)

Usage

Require it via Composer as follow:, (*5)

$ composer require nuvoleweb/drupal-component-scaffold --dev

List all your dependencies (core version, modules, etc.) and run:, (*6)

$ composer update

For example, take the following composer.json:, (*7)

{
  "name": "drupal/my_module",
  "type": "drupal-module",
  "require": {
    "drupal/ds": "~3"
  },
  "require-dev": {
    "nuvoleweb/drupal-component-scaffold": "*",
    "drush/drush": "~8.0",
    "drupal/core": "~8",
    "drupal/panels": "~4",
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://packages.drupal.org/8"
    }
  ],
  "extra": {
    "installer-paths": {
      "web/core": ["type:drupal-core"],
      "web/modules/contrib/{$name}": ["type:drupal-module"]
    }
  }  
}

Running composer install will result in:, (*8)

.
โ”œโ”€โ”€ web
โ”‚ย ย  โ”œโ”€โ”€ autoload.php
โ”‚ย ย  โ”œโ”€โ”€ core
โ”‚ย ย  โ”œโ”€โ”€ modules
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ contrib
โ”‚ย ย  โ”‚ย ย  โ”‚ ย ย  โ””โ”€โ”€ panels
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ custom
โ”‚ย ย  โ”‚ย ย   ย ย  โ””โ”€โ”€ my_module (symlink to project root)
โ”‚ย ย  โ””โ”€โ”€ sites
โ”‚ย ย   ย ย  โ”œโ”€โ”€ default
โ”‚ย ย   ย ย  โ”‚ย ย  โ”œโ”€โ”€ default.services.yml
โ”‚ย ย   ย ย  โ”‚ย ย  โ”œโ”€โ”€ default.settings.php
โ”‚ย ย   ย ย  โ”‚ย ย  โ”œโ”€โ”€ drushrc.php
โ”‚ย ย   ย ย  โ”‚ย ย  โ””โ”€โ”€ settings.local.php
โ”‚ย ย   ย ย  โ”œโ”€โ”€ development.services.yml
โ”‚ย ย   ย ย  โ”œโ”€โ”€ example.settings.local.php
โ”‚ย ย   ย ย  โ””โ”€โ”€ example.sites.php
โ”œโ”€โ”€ vendor
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ composer.lock
โ”œโ”€โ”€ my_module.info.yml
โ””โ”€โ”€ my_module.module

Configuration

Build directory will be derived by the installer-paths, make sure you specify there where you wish to install your core, modules etc:, (*9)

{
  "extra": {
    "installer-paths": {
      "web/core": ["type:drupal-core"],
      "web/modules/contrib/{$name}": ["type:drupal-module"]
    }
  }
}

Also, all options for Drupal Scaffold still apply, check the project's documentation for more., (*10)

Component scaffolding can be triggered at any time by running:, (*11)

$ composer drupal-component-scaffold

Setup PHPUnit tests

To setup PHPUnit use the following phpunit.xml.dist template:, (*12)

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" backupGlobals="true" colors="true" >
  <php>
    <ini name="error_reporting" value="32767"/>
    <var name="namespaces" value=""/>
    <ini name="memory_limit" value="-1"/>
    <env name="SIMPLETEST_DB" value="mysql://user:pass@host/database"/>
  </php>
  <testsuites>
    <testsuite>
      <directory>./tests/</directory>
    </testsuite>
  </testsuites>
</phpunit>

This will ensure that both Unit and Kernel tests tests will ran correctly. See an example here., (*13)

Inner workings

When fired the plugin will:, (*14)

After Drupal Scaffold is done the plugin will:, (*15)

  • Prepare a custom projects directory at ./web/modules/custom.
  • Make ./web/sites/default writable.
  • Symlink your project at ./web/modules/custom/my_module (or at ./web/themes/custom/my_theme).
  • Setup default Drush configuration file at ./web/sites/default/drushrc.php.
  • Make sure that Twig cache is disabled on ./web/sites/development.services.yml.
  • Setup local development settings at ./web/sites/default/settings.local.php.
  • Patch Drupal core with kernel-test-base.patch allowing Kernel tests to run smoothly.

Note: the local development settings file above is disabled by default, to enable it un-comment the related lines in your settings.php file and clear the cache., (*16)

The Versions

01/12 2017

dev-master

9999999-dev https://github.com/nuvoleweb/drupal-component-scaffold

Scaffolding Composer plugin for Drupal modules and themes.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Nuvole Web

scaffold drupal composer-plugin

09/10 2017

0.1.0

0.1.0.0

Scaffolding Composer plugin for Drupal modules and themes.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Nuvole Web