Top Banner
Faster and Smarter Development with Drupal Console
100

Faster and Smarter Development with Drupal Console

Apr 14, 2017

Download

Technology

FFW
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Faster and Smarter Development with Drupal Console

FasterandSmarterDevelopmentwithDrupal

Console

Page 2: Faster and Smarter Development with Drupal Console

JesusManuelOlivas

Drupal8SolutionsEngineer|

IworkforFFW(andyoushouldtoo)

Aboutme

@jmolivas @drupalconsole@drupodcast

Page 3: Faster and Smarter Development with Drupal Console

WhatistheDrupalConsole?

Itisasuiteoftoolsthatyourunonacommandlineinterface(CLI)togenerate

boilerplatecodeandinteractwithaDrupal8installation.

Page 4: Faster and Smarter Development with Drupal Console

DavidFlores|@dmouse

EduardoGarcía|@enzolutions

JesúsManuelOlivas|@jmolivas

OmarAguirre|@omers

Whomaintainthisproject?

Page 6: Faster and Smarter Development with Drupal Console

Whyshouldyoucareaboutit?

Page 7: Faster and Smarter Development with Drupal Console

Drupalismoretehcnicallyadvanced

Page 8: Faster and Smarter Development with Drupal Console

HowdoesDrupalConsolehelp?

Page 9: Faster and Smarter Development with Drupal Console

Topics

WheretofindandhowtoDownloadDrupalConsole

Generatecode/filesrequiredbyaDrupal8module.

InteractwithyourDrupal8installation.

LearnDrupal8.

Writeanintegration.

Automatecommandexecution.

Remotecommandexecution.

ContributetotheprojectandRoadmap.

Page 10: Faster and Smarter Development with Drupal Console

Wheredoyou ndtheproject?

Page 11: Faster and Smarter Development with Drupal Console

LandingPage

Documentation

Support

http://drupalconsole.com/

http://bit.ly/console-book

http://bit.ly/console-support

Page 12: Faster and Smarter Development with Drupal Console

DownloadDrupalConsole

Page 13: Faster and Smarter Development with Drupal Console

UsingtheInstaller

InstalltheConsolelocallybyrunningtheinstallerinyourprojectdirectory:

$ curl http://drupalconsole.com/installer | php

$ mv console.phar /usr/local/bin/drupal

$ drupal

Page 14: Faster and Smarter Development with Drupal Console
Page 15: Faster and Smarter Development with Drupal Console

UsingComposer

$ composer global require drupal/console:@stable

# download at: # ~/.composer/vendor/drupal/console

# run it using:$ ~/.composer/vendor/bin/console

Gitbook-UsingComposer

Page 16: Faster and Smarter Development with Drupal Console

UsingDrupalComposer

$ composer create-project drupal-composer/drupal-project:8.x-dev drupal8.dev --stability dev --no-interaction

https://github.com/drupal-composer/drupal-project

Page 17: Faster and Smarter Development with Drupal Console

UsingaVirtualMachine

DrupalVM

AVMforlocalDrupaldevelopment

Drupal8SprintBox

SimpleDrupal8DevelopmentEnvironment

http://www.drupalvm.com/

https://github.com/thom8/drupal8-vagrant

Page 18: Faster and Smarter Development with Drupal Console

Updatingtheproject

Dependingonthedownloadmethod:

$ drupal self-update

$ console self-update

$ php console.phar self-update

Page 19: Faster and Smarter Development with Drupal Console

Copycon guration les

$ drupal init

# ~/.console/config.yml# ~/.console/chain/sample.yml

Page 20: Faster and Smarter Development with Drupal Console

Generatethecodeand lesrequiredbyaDrupal8module.

Page 21: Faster and Smarter Development with Drupal Console

generate:module

Page 22: Faster and Smarter Development with Drupal Console
Page 23: Faster and Smarter Development with Drupal Console

generate:controller

Page 24: Faster and Smarter Development with Drupal Console
Page 25: Faster and Smarter Development with Drupal Console
Page 26: Faster and Smarter Development with Drupal Console
Page 27: Faster and Smarter Development with Drupal Console

generate:form:con g

Page 28: Faster and Smarter Development with Drupal Console
Page 29: Faster and Smarter Development with Drupal Console

example.routing.yml

Page 30: Faster and Smarter Development with Drupal Console

src/Form/ExampleForm.php

Page 31: Faster and Smarter Development with Drupal Console

src/Form/ExampleForm.php

Page 32: Faster and Smarter Development with Drupal Console

src/Form/ExampleForm.php

Page 33: Faster and Smarter Development with Drupal Console

generate:plugin:block

$ drupal generate:plugin:block --module="example" --class-name="ExampleBlock" --label="example_block" --plugin-id="example_block" --no-interaction

Page 34: Faster and Smarter Development with Drupal Console
Page 35: Faster and Smarter Development with Drupal Console
Page 36: Faster and Smarter Development with Drupal Console

generate:entity:content

$ drupal generate:entity:content --module="example" --entity-class="Foo" --entity-name="foo" --no-interaction

Page 37: Faster and Smarter Development with Drupal Console
Page 38: Faster and Smarter Development with Drupal Console

Othergenerators

generate:authentication:provider generate:entity:config generate:event:subscriber generate:permissions generate:plugin:field generate:plugin:fieldformatter generate:plugin:fieldtype generate:plugin:fieldwidget generate:plugin:imageeffect generate:plugin:rest:resource generate:plugin:rulesaction generate:plugin:type:annotation generate:plugin:type:yaml generate:service generate:theme

Page 39: Faster and Smarter Development with Drupal Console

InteractwithyourDrupalinstallation.

Page 40: Faster and Smarter Development with Drupal Console

site:new

Page 41: Faster and Smarter Development with Drupal Console

site:install

Page 42: Faster and Smarter Development with Drupal Console

container:debug

Page 43: Faster and Smarter Development with Drupal Console

router:debug

Page 44: Faster and Smarter Development with Drupal Console

router:debug

Page 45: Faster and Smarter Development with Drupal Console

site:mode

Page 46: Faster and Smarter Development with Drupal Console

site

site site:maintenance [ON/OFF] site:status

Page 47: Faster and Smarter Development with Drupal Console

con g

config config:debug config:edit config:export config:export:content:type config:export:single config:export:view config:import config:import:single config:override

Page 48: Faster and Smarter Development with Drupal Console

user

user user:login:clear:attempts user:login:url user:password:hash user:password:reset

Page 49: Faster and Smarter Development with Drupal Console

LearnDrupal8.

Page 50: Faster and Smarter Development with Drupal Console

Use--learningoption

$ drupal generate:controller --module="example" --class-name="ExampleController" --method-name="hello" --route="/hello/{name}" --learning --no-interaction

Page 51: Faster and Smarter Development with Drupal Console
Page 52: Faster and Smarter Development with Drupal Console

Writeanintegration

Page 53: Faster and Smarter Development with Drupal Console

generate:command

$ drupal generate:command --module="example" --class-name="HelloCommand" --command="example:hello" --no-interaction

Page 54: Faster and Smarter Development with Drupal Console
Page 55: Faster and Smarter Development with Drupal Console

webpro ler

https://www.drupal.org/project/webpro ler

Page 56: Faster and Smarter Development with Drupal Console

webpro ler:benchmark

Page 57: Faster and Smarter Development with Drupal Console

webpro ler

webprofiler:benchmark webprofiler:export webprofiler:list

Page 58: Faster and Smarter Development with Drupal Console

Automatecommandexecution

Page 59: Faster and Smarter Development with Drupal Console

chain

$ drupal chain --file=~/path/to/start-project.yml

Page 60: Faster and Smarter Development with Drupal Console
Page 61: Faster and Smarter Development with Drupal Console

Remotecommandexecution

Page 62: Faster and Smarter Development with Drupal Console

site:debug

$ drupal site:debug

$ drupal site:debug sample.dev

# Sites configuration files at:# ~/.console/sites/

Page 63: Faster and Smarter Development with Drupal Console

--target

$ drupal --target=sample.dev c:r all

Page 64: Faster and Smarter Development with Drupal Console
Page 65: Faster and Smarter Development with Drupal Console

Tips

Page 66: Faster and Smarter Development with Drupal Console

#Protip1Use--rootoption

$ drupal --root=/var/www/drupal8.dev

Page 67: Faster and Smarter Development with Drupal Console

#Protip2Usemultilanguagefeature

# ~/.console/config.yml

application: environment: 'prod' language: en #available: en,es,fr,hu,pt,ro editor: vim temp: /tmp

Page 68: Faster and Smarter Development with Drupal Console
Page 69: Faster and Smarter Development with Drupal Console
Page 70: Faster and Smarter Development with Drupal Console

#Protip3Usedefaultvalues

# ~/.console/config.ymlapplication:

...

default: commands: generate: controller: options: module: my_current_project

Page 71: Faster and Smarter Development with Drupal Console

#Protip4Disablecontributedcommands

# ~/.console/config.ymlapplication:

...

disable: modules: - broken_module_name_one - broken_module_name_two

Page 72: Faster and Smarter Development with Drupal Console

#Protip5Usecommandalias

$ drupal cache:rebuild all

$ drupal c:r all

Page 73: Faster and Smarter Development with Drupal Console

#Protip6Use--helpoption

$ drupal generate:module --help

Page 74: Faster and Smarter Development with Drupal Console
Page 75: Faster and Smarter Development with Drupal Console

#Protip7Use--generate-inline

$ drupal generate:entity:config --generate-inline

Page 76: Faster and Smarter Development with Drupal Console
Page 77: Faster and Smarter Development with Drupal Console

#Protip8Use--generate-chain

$ drupal generate:module --generate-chain

Page 78: Faster and Smarter Development with Drupal Console
Page 79: Faster and Smarter Development with Drupal Console

#Protip9Use--generate-doc

$ drupal webprofiler:benchmark --generate-doc

Page 80: Faster and Smarter Development with Drupal Console
Page 81: Faster and Smarter Development with Drupal Console

#Protip10Usepecocommand

$ drupal router:debug | peco | awk -F ' ' '{print $1}' | xargs drupal router:debug

https://github.com/peco/peco

Page 82: Faster and Smarter Development with Drupal Console
Page 83: Faster and Smarter Development with Drupal Console

Howtocontribute?

Page 84: Faster and Smarter Development with Drupal Console

Gettingtheproject

ForkyourowncopyoftheConsolerepository

Cloneyourforkedrepository.

$ git clone [email protected]:[github-user]/DrupalConsole.git

Downloaddependenciesusingcomponser.

$ cd /path/to/DrupalConsole$ composer install

http://bit.ly/console-fork

Page 85: Faster and Smarter Development with Drupal Console

Beforecommitingyourcode

ProjectcodeisPSR-2CodingStyle.

GeneratedcodeisDrupalCodingStyle.

http://www.php-fig.org/psr/psr-2/

https://www.drupal.org/coding-standards

Page 86: Faster and Smarter Development with Drupal Console

Codeanalysis

http://bit.ly/console-insight

http://bit.ly/console-travis

Page 87: Faster and Smarter Development with Drupal Console

PHPQAall-in-oneAnalyzerCLItool

PHPParallelLint

PHP_CodeSniffer

PHPLOC

PHPMessDetector

PHPUnit

https://github.com/jmolivas/phpqa

Page 88: Faster and Smarter Development with Drupal Console

RunningPHPQAmanually

$ cd /path/to/DrupalConsole$ phpqa analyze --files=src/

RunningPHPQAautomatically

$ vim .git/hooks/pre-commit# Paste this:phpqa analyze --git

Page 89: Faster and Smarter Development with Drupal Console

jmolivas dmouse enzolutions omero danielnv18 vacho esod cordoval Sutharsan chipkaye hugronaphor

kgaut webflo czettnersandor fluxsauce greg-1-anderson lucasmingarro Crell martinfrances107 bojanz danielrose28

MiguelC301 azarzag Jaesin rpayanm iadyax alexweber mimioc revagomes Chi-teck egulias heilop

LowellMontgomery mmenavas sethfischer emacoti jeqq benjy carlosroh edutrul albertvolkman jjcarrion dasjo

joshuataylor kendallsv kostajh lussoluca stevector ysramirez brantwynn langelhc

Contributors

Page 90: Faster and Smarter Development with Drupal Console

Spreadthewordandlove.

@drupalconsole|#drupalconsole

/~drupalconsole

Page 91: Faster and Smarter Development with Drupal Console

Roadmap

Page 92: Faster and Smarter Development with Drupal Console

Increasecodecoverage.

Multi-sitesupport.

Improvedocumentationandtranslations.

Improveverbosecode-output.

Dummycontentgeneration.

Page 93: Faster and Smarter Development with Drupal Console

Milestones

https://github.com/hechoendrupal/DrupalConsole/milestones

Page 94: Faster and Smarter Development with Drupal Console

Upcommingimplementations

Metatag

Rules

[Yourmodulehere]

Page 95: Faster and Smarter Development with Drupal Console

Let'sworktogethertomake

awesometoolsevenbetter.

Page 96: Faster and Smarter Development with Drupal Console

Drushintegration

https://github.com/drush-ops/drush/pull/1337

Page 97: Faster and Smarter Development with Drupal Console

Onemorething...

Page 98: Faster and Smarter Development with Drupal Console

GUIfortheCLI.

Page 99: Faster and Smarter Development with Drupal Console

http://drupalgenerator.com/

Page 100: Faster and Smarter Development with Drupal Console

Questions&Feedback

Feelfreetostalkmeoraskanyquestionat:

@jmolivas|@drupalconsole