Skip to content

Instantly share code, notes, and snippets.

@jmolivas
Last active June 12, 2017 00:56
Show Gist options
  • Save jmolivas/31287c9de9b50d4c191d to your computer and use it in GitHub Desktop.
Save jmolivas/31287c9de9b50d4c191d to your computer and use it in GitHub Desktop.
YDD => YAML Driven Development using sample YAML file distributed with Drupal Console, original file path: https://github.com/hechoendrupal/DrupalConsole/blob/master/config/dist/chain/sample.yml

Instructions

You must have Drupal Console 0.10.4+ installed to test this.

Install Drupal Console

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal

Update Drupal Console

drupal self-update

Copy sample.yaml and other configuration files to user home directory

drupal init --override

Execute chain command

cd /path/to/drupal8.dev
drupal chain --file=~/.console/chain/sample.yml

Confirm generated files

tree modules/custom/example/
modules/custom/example/
├── Tests
│   └── Controller
│       └── HelloWorldControllerTest.php
├── config
│   ├── schema
│   │   └── bar.schema.yml
│   └── translations
│       └── console.en.yml
├── example.info.yml
├── example.links.action.yml
├── example.links.menu.yml
├── example.links.task.yml
├── example.permissions.yml
├── example.routing.yml
├── example.services.yml
├── foo.page.inc
├── src
│   ├── Authentication
│   │   └── Provider
│   │       └── ExampleAuthenticationProvider.php
│   ├── BarInterface.php
│   ├── BarListBuilder.php
│   ├── Command
│   │   └── ExampleCommand.php
│   ├── Controller
│   │   └── HelloWorldController.php
│   ├── Entity
│   │   ├── Bar.php
│   │   ├── Foo.php
│   │   └── FooViewsData.php
│   ├── ExampleService.php
│   ├── ExampleServiceInterface.php
│   ├── FooAccessControlHandler.php
│   ├── FooInterface.php
│   ├── FooListBuilder.php
│   ├── Form
│   │   ├── BarDeleteForm.php
│   │   ├── BarForm.php
│   │   ├── FooDeleteForm.php
│   │   ├── FooForm.php
│   │   ├── FooSettingsForm.php
│   │   └── SettingsForm.php
│   └── Plugin
│       ├── Block
│       │   └── ExampleBlock.php
│       ├── ImageEffect
│       │   └── ExampleImageEffect.php
│       └── rest
│           └── resource
│               └── ExampleRestResource.php
└── templates
    └── foo.html.twig

18 directories, 34 files

You can see the content of ~/.console/chain/sample.ymlfile below.

commands:
- command: generate:module
options:
module: Example module
machine-name: example
module-path: /modules/custom/
description: My example module
core: 8.x
package: Custom
dependencies:
- command: generate:controller
options:
module: example
class: HelloWorldController
routes:
- title: 'Hello World'
method: hello
path: 'example/hello/{name}'
test: true
- command: generate:form:config
options:
module: example
class: SettingsForm
form-id: settings_form
inputs:
- name: foo_field
type: textfield
label: 'Foo field'
options: ''
description: ''
maxlength: '64'
size: '64'
default_value: ''
weight: '0'
fieldset: ''
- name: bar_number
type: number
label: 'Bar number'
options: ''
description: ''
maxlength: null
size: null
default_value: ''
weight: '0'
fieldset: ''
routing: true
menu_link_gen: true
menu_link_title: SettingsForm
menu_parent: system.admin_config_system
menu_link_desc: 'A description for the menu entry'
- command: generate:entity:content
options:
module: example
entity-class: Foo
entity-name: foo
- command: generate:entity:config
options:
module: example
entity-class: Bar
entity-name: bar
- command: generate:command
options:
module: example
class: ExampleCommand
name: example:command
container-aware: false
- command: generate:authentication:provider
options:
module: example
class: ExampleAuthenticationProvider
- command: generate:plugin:block
options:
module: example
class: ExampleBlock
label: Example plugin block
plugin-id: example_block
- command: generate:plugin:imageeffect
options:
module: example
class: ExampleImageEffect
plugin-id: example_image_effect
label: Example image effect
description: Example image effect
- command: generate:plugin:rest:resource
options:
module: example
class: ExampleRestResource
plugin-id: example_rest_resource
plugin-label: Example Rest Resource
plugin-url: example_rest_resource
plugin-states: 0, 1, 2
- command: generate:service
options:
module: example
class: ExampleService
name: example.service
interface: yes
- command: module:install
arguments:
module: [example]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment