Fast Paced Drupal 8 Speed up with composer, console and services /@emarchak @myplanetHQ /emarchak.github.io/fastpaced_drupal8 github.com/emarchak/fastpaced_videos
@myplanetHQ
@emarchak
Why Change for D8? 1. Speed up your development process 2. Play well with others
Dependencies Dependency manager for PHP Extends Symfony console for boilerplates and interactions. Guzzle is a PHP HTTP client. Familiarity with Drupal 7 development Composer Drupal Console Guzzle (in core)
Overview 1. Build using Composer 2. Install using Console 3. Create a Module using Console 4. Export Content Types using Console 5. Create Admin Form using Console 6. Create a Service using Console 7. Import Nodes using Guzzle 8. Include your module using Composer
Witness Me!
1. Build using Composer Download Drupal into the docroot. to Drush Make for building sites.Composer is a really exciting alternative $composercreate-projectdrupal/drupaldocroot8.0.5 $cddocroot
Managing patches using composer For Drupal 8.0.5 only, we'll need to , but any module can be patched.patch core $composerrequirecweagans/composer-patches--no-update "extra":{... "patches":{ "drupal/drupal":{ "Combinationof--prefer-distand.gitattributesconfusesourvendortestcleanup" } }
Add to installer paths to let us download modules to ./docroot/modules/contrib "extra":{... "installer-paths":{ "modules/contrib/{$name}":[ "type:drupal-module" ] } },
Add as a repo, so we can download Drupal modules. Drupal Composer "repositories":[{ "type":"composer", "url":"https://packagist.drupal-composer.org" }]
Install some Drupal modules! improves the core Drupal toolbar, and is used in our demo. Admin Toolbar Video Embed Field $composerrequiredrupal/admin_toolbar:8.1.14--no-update $composerrequiredrupal/video_embed_field:8.1.0-rc5--no-update $composerupdate
2. Install using Console $drupalsite:install $drupalmodule:installadmin_toolbar $drupalmodule:installvideo_embed_field
Move the configuration sync directory outside of the docroot, and add .Symfony's new trusted host patterns $config_directories['sync']='../config/sync'; $settings['trusted_host_patterns']=['^fastpaced.local$']; $drupalconfig:export
3. Create a Module using Console Let's create a fast-paced module... $drupalgenerate:module Enterthenewmodulename: >Fastpacedvideos
... and a speedy content type! $drupalgenerate:entity:bundle Enterthemodulename[admin_toolbar]: >fastpaced_videos Enterthemachinenameofyournewcontenttype[default]: >video $drupalmodule:installfastpaced_videos
4. Export Content Types using Console Log into the site and configure the content type as needed, before you export it. $drupalconfig:export:content:type >video Exportcontenttypeinmoduleasanoptionalconfiguration(yes/no)[yes]: >no
Can we generate some example content? Yes we can. $drupalcreate:nodes
5. Create Admin form using Console $drupalgenerate:form:config EntertheFormClassname[DefaultForm]: >ImportSettingsForm Doyouwanttogenerateaformstructure?(yes/no)[yes]: >y Type: number Inputlabel: ImportMax Description: Maximumamountofnodestoimportprecronrun Defaultvalue:10 Type: textfield Inputlabel: SearchTerms Description: Feedtoimportfrom Defaultvalue:macaframa
Export the configuration settings. $drupalconfig:export:single--directory=modules/custom/fastpaced_videos/config/install Configurationtype[Simpleconfiguration]: >system.simple Configurationname[automated_cron.settings]: >fastpaced_videos.importsettings
6. Import Nodes using Guzzle Add fastpaced_videos_cron(). /** *@file *Containsfastpaced_videos.module. */ useDrupalCoreUrl; useDrupalComponentSerializationJson; /** *Implementshook_cron(). */ functionfastpaced_videos_cron(){...} Some parts of Drupal 8 are still procedural like 7, hook_themeand hook_cron, for example. for further changes to fastpaced_videos.moduleRefer to the repo
7. Create a Service using Console We'll be importing videos using guzzle, so we'll need to create a service to save them. $drupalgenerate:service Entertheservicename[fastpaced_videos.default]: >fastpaced_videos.import EntertheClassname[DefaultService]: >ImportService Doyouwanttoloadservicesfromthecontainer(yes/no)[no]: >yes Enteryourservice[]: >entity.query >entity_type.manager for further changes to fastpaced_videos/src/ImportServiceInterface.phpRefer to the repo
8. Add your custom module to composer Add as a repo, so we can can download our custom module. our github repo "repositories":[...{ "type":"git", "url":"https://github.com/emarchak/fastpaced_videos.git" }] $composerrequireemarchak/fastpaced_videos
Ride eternal, shiny and chrome. /@emarchak @myplanetHQ /emarchak.github.io/fastpaced_drupal8 github.com/emarchak/fastpaced_videos

Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console and Services

  • 1.
    Fast Paced Drupal 8 Speedup with composer, console and services /@emarchak @myplanetHQ /emarchak.github.io/fastpaced_drupal8 github.com/emarchak/fastpaced_videos
  • 2.
  • 3.
  • 4.
    Why Change forD8? 1. Speed up your development process 2. Play well with others
  • 5.
    Dependencies Dependency manager forPHP Extends Symfony console for boilerplates and interactions. Guzzle is a PHP HTTP client. Familiarity with Drupal 7 development Composer Drupal Console Guzzle (in core)
  • 6.
    Overview 1. Build usingComposer 2. Install using Console 3. Create a Module using Console 4. Export Content Types using Console 5. Create Admin Form using Console 6. Create a Service using Console 7. Import Nodes using Guzzle 8. Include your module using Composer
  • 7.
  • 8.
    1. Build usingComposer Download Drupal into the docroot. to Drush Make for building sites.Composer is a really exciting alternative $composercreate-projectdrupal/drupaldocroot8.0.5 $cddocroot
  • 9.
    Managing patches usingcomposer For Drupal 8.0.5 only, we'll need to , but any module can be patched.patch core $composerrequirecweagans/composer-patches--no-update "extra":{... "patches":{ "drupal/drupal":{ "Combinationof--prefer-distand.gitattributesconfusesourvendortestcleanup" } }
  • 10.
    Add to installerpaths to let us download modules to ./docroot/modules/contrib "extra":{... "installer-paths":{ "modules/contrib/{$name}":[ "type:drupal-module" ] } },
  • 11.
    Add as arepo, so we can download Drupal modules. Drupal Composer "repositories":[{ "type":"composer", "url":"https://packagist.drupal-composer.org" }]
  • 12.
    Install some Drupalmodules! improves the core Drupal toolbar, and is used in our demo. Admin Toolbar Video Embed Field $composerrequiredrupal/admin_toolbar:8.1.14--no-update $composerrequiredrupal/video_embed_field:8.1.0-rc5--no-update $composerupdate
  • 13.
    2. Install usingConsole $drupalsite:install $drupalmodule:installadmin_toolbar $drupalmodule:installvideo_embed_field
  • 14.
    Move the configurationsync directory outside of the docroot, and add .Symfony's new trusted host patterns $config_directories['sync']='../config/sync'; $settings['trusted_host_patterns']=['^fastpaced.local$']; $drupalconfig:export
  • 15.
    3. Create aModule using Console Let's create a fast-paced module... $drupalgenerate:module Enterthenewmodulename: >Fastpacedvideos
  • 16.
    ... and aspeedy content type! $drupalgenerate:entity:bundle Enterthemodulename[admin_toolbar]: >fastpaced_videos Enterthemachinenameofyournewcontenttype[default]: >video $drupalmodule:installfastpaced_videos
  • 17.
    4. Export ContentTypes using Console Log into the site and configure the content type as needed, before you export it. $drupalconfig:export:content:type >video Exportcontenttypeinmoduleasanoptionalconfiguration(yes/no)[yes]: >no
  • 18.
    Can we generatesome example content? Yes we can. $drupalcreate:nodes
  • 19.
    5. Create Adminform using Console $drupalgenerate:form:config EntertheFormClassname[DefaultForm]: >ImportSettingsForm Doyouwanttogenerateaformstructure?(yes/no)[yes]: >y Type: number Inputlabel: ImportMax Description: Maximumamountofnodestoimportprecronrun Defaultvalue:10 Type: textfield Inputlabel: SearchTerms Description: Feedtoimportfrom Defaultvalue:macaframa
  • 20.
    Export the configurationsettings. $drupalconfig:export:single--directory=modules/custom/fastpaced_videos/config/install Configurationtype[Simpleconfiguration]: >system.simple Configurationname[automated_cron.settings]: >fastpaced_videos.importsettings
  • 21.
    6. Import Nodesusing Guzzle Add fastpaced_videos_cron(). /** *@file *Containsfastpaced_videos.module. */ useDrupalCoreUrl; useDrupalComponentSerializationJson; /** *Implementshook_cron(). */ functionfastpaced_videos_cron(){...} Some parts of Drupal 8 are still procedural like 7, hook_themeand hook_cron, for example. for further changes to fastpaced_videos.moduleRefer to the repo
  • 22.
    7. Create aService using Console We'll be importing videos using guzzle, so we'll need to create a service to save them. $drupalgenerate:service Entertheservicename[fastpaced_videos.default]: >fastpaced_videos.import EntertheClassname[DefaultService]: >ImportService Doyouwanttoloadservicesfromthecontainer(yes/no)[no]: >yes Enteryourservice[]: >entity.query >entity_type.manager for further changes to fastpaced_videos/src/ImportServiceInterface.phpRefer to the repo
  • 23.
    8. Add yourcustom module to composer Add as a repo, so we can can download our custom module. our github repo "repositories":[...{ "type":"git", "url":"https://github.com/emarchak/fastpaced_videos.git" }] $composerrequireemarchak/fastpaced_videos
  • 24.
    Ride eternal, shinyand chrome. /@emarchak @myplanetHQ /emarchak.github.io/fastpaced_drupal8 github.com/emarchak/fastpaced_videos