94
Faster and Smarter Development with Drupal Console

[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Embed Size (px)

Citation preview

Page 1: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

FasterandSmarterDevelopmentwithDrupal

Console

Page 2: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

JesusManuelOlivas

Drupal8SolutionsEngineer|

IworkforFFW(andyoushouldtoo)

Aboutme

@jmolivas @drupalconsole@drupodcast

Page 3: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

WhatistheDrupalConsole?

Itisasuiteoftoolsthatyourunonacommandlineinterface(CLI)togenerate

boilerplatecodeandinteractwithaDrupal8installation.

Page 4: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

DavidFlores|@dmouse

EduardoGarcía|@enzolutions

JesúsManuelOlivas|@jmolivas

OmarAguirre|@omers

Whomaintainthisproject?

Page 6: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Whyshouldyoucareaboutit?

Page 7: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Drupalismoretehcnicallyadvanced

Page 8: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

HowdoesDrupalConsolehelp?

Page 9: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Generatingthecodeand lesrequiredbyaDrupal8module.

InteractingwithyourDrupalinstallation.

LearningDrupal8.

Page 10: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

WheredoI ndtheproject?

Page 11: [Srijan Wednesday Webinars] 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: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

DownloadDrupalConsole

Page 13: [Srijan Wednesday Webinars] 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: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 15: [Srijan Wednesday Webinars] 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: [Srijan Wednesday Webinars] 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: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

UsingaVirtualMachine

DrupalVM

AVMforlocalDrupaldevelopment

Drupal8SprintBox

SimpleDrupal8DevelopmentEnvironment

http://www.drupalvm.com/

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

Page 18: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Updatingtheproject

Dependingonthedownloadmethod:

$ drupal self-update

$ console self-update

$ php console.phar self-update

Page 19: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

WhatcanyoudowithDrupalConsole?

Page 20: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Generatethecodeand lesrequiredbyaDrupal8module.

Page 21: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

generate:module

Page 22: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 23: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

generate:form:con g

Page 24: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 25: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

example.routing.yml

Page 26: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

src/Form/ExampleForm.php

Page 27: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

src/Form/ExampleForm.php

Page 28: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

src/Form/ExampleForm.php

Page 29: [Srijan Wednesday Webinars] 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 30: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 31: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 32: [Srijan Wednesday Webinars] 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 33: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 34: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

generate:theme

$ drupal generate:theme

Page 35: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 36: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Othergenerators

generate:authentication:provider generate:entity:config 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

Page 37: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

InteractwithyourDrupalinstallation.

Page 38: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

container:debug

Page 39: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

router:debug

Page 40: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

router:debug

Page 41: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

site:mode

Page 42: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

site

site site:maintenance [ON/OFF] site:mode [DEV/PROD] site:new [DIRECTORY_NAME] site:status

Page 43: [Srijan Wednesday Webinars] 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 44: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

user

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

Page 45: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

LearnDrupal8.

Page 46: [Srijan Wednesday Webinars] 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 47: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 48: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Writeanintegration

Page 49: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

generate:command

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

Page 50: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 51: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

webpro ler

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

Page 52: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

webpro ler:benchmark

Page 53: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

webpro ler

webprofiler:benchmark webprofiler:export webprofiler:list

Page 54: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Automatecommandexecution

Page 55: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

chain

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

Page 56: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 57: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Tips

Page 58: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip1Copycon guration les

$ drupal init

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

Page 59: [Srijan Wednesday Webinars] 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 60: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 61: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 62: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip3Usedefaultvalues

# ~/.console/config.ymlapplication:

...

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

Page 63: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip4Disablecontributedcommands

# ~/.console/config.ymlapplication:

...

disable: modules: - broken_module_name_one - broken_module_name_two

Page 64: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip5Usecommandalias

$ drupal cache:rebuild all

$ drupal c:r all

Page 65: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip6Use--helpoption

$ drupal generate:module --help

Page 66: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 67: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip7Use--generate-inline

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

Page 68: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 69: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip8Use--generate-chain

$ drupal generate:module --generate-chain

Page 70: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 71: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

#Protip9Use--generate-doc

$ drupal webprofiler:benchmark --generate-doc

Page 72: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 73: [Srijan Wednesday Webinars] 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 74: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Page 75: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Howtocontribute?

Page 76: [Srijan Wednesday Webinars] 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 77: [Srijan Wednesday Webinars] 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 78: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Codeanalysis

http://bit.ly/console-insight

http://bit.ly/console-travis

Page 79: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

PHPQAall-in-oneAnalyzerCLItool

PHPParallelLint

PHP_CodeSniffer

PHPLOC

PHPMessDetector

PHPUnit

https://github.com/jmolivas/phpqa

Page 80: [Srijan Wednesday Webinars] 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 81: [Srijan Wednesday Webinars] 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 82: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Wherearetheyfrom

Page 83: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Spreadthewordandlove.

@drupalconsole|#drupalconsole

/~drupalconsole

Page 84: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Roadmap

Page 85: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Remotecommandexecution.

Increasecodecoverage.

Multi-sitesupport.

Improvedocumentationandtranslations.

Improveverbosecode-output.

Dummycontentgeneration.

Con gstagingexport/import.

Contentstagingexport/import.

Page 86: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Milestones

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

Page 87: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Upcommingimplementations

Metatag

Rules

[Yourmodulehere]

Page 88: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Let'sworktogethertomake

awesometoolsevenbetter.

Page 89: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Drushintegration

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

Page 90: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Onemorething...

Page 91: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

GUIfortheCLI.

Page 92: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

http://drupalgenerator.com/

Page 93: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

JoinusatDrupalConAsia2016sprints

EduardoGarcía|@enzolutionswillbeattending.

Page 94: [Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console

Questions&Feedback

Feelfreetostalkmeoraskanyquestionat:

@jmolivas|@drupalconsole