Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nuvoleweb/drupal-component-scaffold
Scaffolding Composer plugin for Drupal modules and themes.
https://github.com/nuvoleweb/drupal-component-scaffold
composer-plugin drupal drupal-8
Last synced: 2 months ago
JSON representation
Scaffolding Composer plugin for Drupal modules and themes.
- Host: GitHub
- URL: https://github.com/nuvoleweb/drupal-component-scaffold
- Owner: nuvoleweb
- License: gpl-2.0
- Created: 2017-09-16T20:54:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-01T11:07:59.000Z (about 7 years ago)
- Last Synced: 2024-04-27T01:21:21.429Z (9 months ago)
- Topics: composer-plugin, drupal, drupal-8
- Language: PHP
- Size: 32.2 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Drupal Component Scaffold
[![Build Status](https://travis-ci.org/nuvoleweb/drupal-component-scaffold.svg?branch=master)](https://travis-ci.org/nuvoleweb/drupal-component-scaffold)
*Drupal Component Scaffold* is a [Composer plugin](https://getcomposer.org/doc/articles/plugins.md) 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.Once installed the plugin allows to:
- 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](https://github.com/nuvoleweb/ui_patterns/blob/8.x-1.x/composer.json).
- 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](https://github.com/nuvoleweb/ui_patterns/blob/8.x-1.x/.travis.yml).The plugin leverages the excellent [Drupal Scaffold](https://github.com/drupal-composer/drupal-scaffold) project and
fires only after (and if) its main scaffolding tasks are ran.## Usage
Require it via Composer as follow:
```
$ composer require nuvoleweb/drupal-component-scaffold --dev
```List all your dependencies (core version, modules, etc.) and run:
```
$ composer update
```For example, take the following `composer.json`:
```json
{
"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:
```
.
├── 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:```json
{
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/modules/contrib/{$name}": ["type:drupal-module"]
}
}
}
```Also, all options for [Drupal Scaffold](https://github.com/drupal-composer/drupal-scaffold) still apply, check the
project's documentation for more.Component scaffolding can be triggered at any time by running:
```
$ composer drupal-component-scaffold
```## Setup PHPUnit tests
To setup [PHPUnit](https://phpunit.de) use the following `phpunit.xml.dist` template:
```xml
./tests/
```
This will ensure that both [Unit and Kernel](https://www.drupal.org/docs/8/testing/types-of-tests-in-drupal-8) tests
tests will ran correctly. [See an example here](https://github.com/nuvoleweb/ui_patterns/blob/8.x-1.x/phpunit.xml.dist).## Inner workings
When fired the plugin will:
- Setup [Composer Installers](https://github.com/composer/installers) paths.
- Register a post-[Drupal Scaffold](https://github.com/drupal-composer/drupal-scaffold) event handler.After Drupal Scaffold is done the plugin will:
- 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](dist/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.