Faster and Smarter Development with Drupal Console

Post on 14-Apr-2017

432 views 2 download

transcript

FasterandSmarterDevelopmentwithDrupal

Console

JesusManuelOlivas

Drupal8SolutionsEngineer|

IworkforFFW(andyoushouldtoo)

Aboutme

@jmolivas @drupalconsole@drupodcast

WhatistheDrupalConsole?

Itisasuiteoftoolsthatyourunonacommandlineinterface(CLI)togenerate

boilerplatecodeandinteractwithaDrupal8installation.

DavidFlores|@dmouse

EduardoGarcía|@enzolutions

JesúsManuelOlivas|@jmolivas

OmarAguirre|@omers

Whomaintainthisproject?

Whyshouldyoucareaboutit?

Drupalismoretehcnicallyadvanced

HowdoesDrupalConsolehelp?

Topics

WheretofindandhowtoDownloadDrupalConsole

Generatecode/filesrequiredbyaDrupal8module.

InteractwithyourDrupal8installation.

LearnDrupal8.

Writeanintegration.

Automatecommandexecution.

Remotecommandexecution.

ContributetotheprojectandRoadmap.

Wheredoyou ndtheproject?

LandingPage

Documentation

Support

http://drupalconsole.com/

http://bit.ly/console-book

http://bit.ly/console-support

DownloadDrupalConsole

UsingtheInstaller

InstalltheConsolelocallybyrunningtheinstallerinyourprojectdirectory:

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

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

$ drupal

UsingComposer

$ composer global require drupal/console:@stable

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

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

Gitbook-UsingComposer

UsingDrupalComposer

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

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

UsingaVirtualMachine

DrupalVM

AVMforlocalDrupaldevelopment

Drupal8SprintBox

SimpleDrupal8DevelopmentEnvironment

http://www.drupalvm.com/

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

Updatingtheproject

Dependingonthedownloadmethod:

$ drupal self-update

$ console self-update

$ php console.phar self-update

Copycon guration les

$ drupal init

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

Generatethecodeand lesrequiredbyaDrupal8module.

generate:module

generate:controller

generate:form:con g

example.routing.yml

src/Form/ExampleForm.php

src/Form/ExampleForm.php

src/Form/ExampleForm.php

generate:plugin:block

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

generate:entity:content

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

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

InteractwithyourDrupalinstallation.

site:new

site:install

container:debug

router:debug

router:debug

site:mode

site

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

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

user

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

LearnDrupal8.

Use--learningoption

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

Writeanintegration

generate:command

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

webpro ler

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

webpro ler:benchmark

webpro ler

webprofiler:benchmark webprofiler:export webprofiler:list

Automatecommandexecution

chain

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

Remotecommandexecution

site:debug

$ drupal site:debug

$ drupal site:debug sample.dev

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

--target

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

Tips

#Protip1Use--rootoption

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

#Protip2Usemultilanguagefeature

# ~/.console/config.yml

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

#Protip3Usedefaultvalues

# ~/.console/config.ymlapplication:

...

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

#Protip4Disablecontributedcommands

# ~/.console/config.ymlapplication:

...

disable: modules: - broken_module_name_one - broken_module_name_two

#Protip5Usecommandalias

$ drupal cache:rebuild all

$ drupal c:r all

#Protip6Use--helpoption

$ drupal generate:module --help

#Protip7Use--generate-inline

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

#Protip8Use--generate-chain

$ drupal generate:module --generate-chain

#Protip9Use--generate-doc

$ drupal webprofiler:benchmark --generate-doc

#Protip10Usepecocommand

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

https://github.com/peco/peco

Howtocontribute?

Gettingtheproject

ForkyourowncopyoftheConsolerepository

Cloneyourforkedrepository.

$ git clone git@github.com:[github-user]/DrupalConsole.git

Downloaddependenciesusingcomponser.

$ cd /path/to/DrupalConsole$ composer install

http://bit.ly/console-fork

Beforecommitingyourcode

ProjectcodeisPSR-2CodingStyle.

GeneratedcodeisDrupalCodingStyle.

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

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

Codeanalysis

http://bit.ly/console-insight

http://bit.ly/console-travis

PHPQAall-in-oneAnalyzerCLItool

PHPParallelLint

PHP_CodeSniffer

PHPLOC

PHPMessDetector

PHPUnit

https://github.com/jmolivas/phpqa

RunningPHPQAmanually

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

RunningPHPQAautomatically

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

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

Spreadthewordandlove.

@drupalconsole|#drupalconsole

/~drupalconsole

Roadmap

Increasecodecoverage.

Multi-sitesupport.

Improvedocumentationandtranslations.

Improveverbosecode-output.

Dummycontentgeneration.

Milestones

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

Upcommingimplementations

Metatag

Rules

[Yourmodulehere]

Let'sworktogethertomake

awesometoolsevenbetter.

Drushintegration

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

Onemorething...

GUIfortheCLI.

http://drupalgenerator.com/

Questions&Feedback

Feelfreetostalkmeoraskanyquestionat:

@jmolivas|@drupalconsole