SlideShare a Scribd company logo
Drupal 8 CLI
Command line interface
Recap
1. Introduction to drush and drupal console.
2. Comparison between drush and drupal console.
3. Drupal console installation.
4. How to use drush.
5. Scaffolding.
6. Tree structure using command.
7. Create virtual server using drush.
Precap
1. What is Drupal Console?
2. Why Drupal Console?
3. How to use drupal console.
4. Generate a module.
5. Generate an entity.
6. Generate a profile.
7. Generate a theme.
8. Generate a custom command.
What is drupal console?
The Drupal Console is, at this time, a suite of tools that you run on a command
line interface(CLI) to generate boilerplate code and interact with a Drupal 8
installation.
Similar tools include:
1. Module Builder: Generate Drupal 6,7 or 8 module scaffolding.
2. Drupal Module Upgrader: Converts modules from Drupal 7 to Drupal 8,
generated static help files with links to relevant change records.
3. Drupal 8 Tools: Drupal code generator written in bash.
4. Drush: Interact with Drupal installation via CLI, creates aliases, create custom
Why Drupal Console?
Drupal Console provides a number of commands for creating module scaffolding
and boilerplate code. For any command, you will be asked a series of questions
about what you want. In the case of module scaffolding, files are created and
inside these files, classes—complete with namespacing and use statements—are
created for you with the naming convention you specified in the command's
prompts.
The Drupal Console isn't a Drupal module, but was built with the Symfony Console
Component and other libraries, such as Twig, to generate PHP, YAML, and other
file types used in Drupal 8 module development. It is a tool designed for anyone
using or planning to use Drupal 8. At the moment, it is used via a CLI, but there
are plans to make it accessible through the Drupal administrative interface.
How does Drupal Console differ from Drupal Module
Upgrader?
Drupal Module Upgrader takes a Drupal 7 module and attempts to port it to Drupal
8. While it generates files like Drupal Console does, Drupal Console generates
module scaffolding and code based on a series of interactive prompts, instead of
analyzing an existing module and converting it to work in Drupal 8.
How does Drupal Console compare to Drush?
There are many similarities between these two tools, but the main difference is
how it was built, using an object-oriented architecture and Symfony components.
Who is the intended audience for the Drupal
Console?
Any developer who will be responsible for writing custom code in Drupal 8. Any
organization that will benefit from its vast potential.
As such, the following groups in particular could find this tool advantageous to add
to their learning Drupal 8 toolkit:
1. Enterprises and other organizations to reduce development time and reduce
custom development risk factors.
2. Drupal 8 module maintainers and developers to speed up development and
testing.
3. Drupal trainers and consultants providing Drupal 8 developer training.
What features are planned for development?
1. Verbose code output for learning and leveraging docblocks
2. Complete config:import, site:status, and few a few other commands.
3. Import/export content between Drupal installations
4. Site Aliases
5. Generate dummy content, probably using PHP Faker library or Default
Content project.
6. Add a GUI for Drupal Console as an alternative to the CLI. This could be
especially useful for site builders wanting to generate dummy content or issue
site commands without needing to use the command line. It could also be
How to use drupal console?
1. You can install it using curl
curl https://drupalconsole.com/installer -L -o drupal.phar
2. Using PHP in CLI
php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
3. Using Composer
composer global require drupal/console:@stable
Generate a module
For generating a custom module we can use below command for a fresh drupal 8
custom module generation. Please note you must be in a drupal 8 project
directory.
drupal generate:module
It will lead you to interactive CLI and will need some inputs from your side and
generates the custom module.
Generate an entity
For generating a custom entity we can use below command for a fresh drupal 8
entity generation inside a custom module. Please note you must be in a drupal 8
project directory.
drupal generate:entity:config
It will lead you to interactive CLI and will need some inputs from your side and
generates the custom entity along with its table.
It also provides admin interface for managing the created entity(Asked on the
CLI).
Generate a profile
For generating a custom profile we can use below command for a drupal 8 profile.
Please note you must be in a drupal 8 project directory.
drupal generate:profile
It will lead you to interactive CLI and will need some inputs from your side and
generates the profile and can be developed as distribution.
Generate a Custom Command
We can generate a custom drupal console command too. For generating a custom
command we can use below command. Please note you must be in a drupal 8
project directory and it will ask you for a module where the new command can be
inserted..
drupal generate:command
It will lead you to interactive CLI and will need some inputs from your side and
generates the command along with some example to show interactive feature.
Introduction to command class
As we are using symphony for drupal, it provides interaction with CLI using its
console package command class which present at below path.
vendor/symfony/console/Command/Command.php
Drupal also inherited this class and generates its own class. All the drupal console
commands generated using the above classes and can be available for CLI
interaction.
Command class structure and understanding
If we want to generate a custom command, we should use below namespaces.
use SymfonyComponentConsoleInputInputArgument;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleInputInputOption;
use SymfonyComponentConsoleOutputOutputInterface;
use DrupalConsoleCommandCommand;
use DrupalConsoleStyleDrupalStyle;
Also our custom class package must be extend Command base class. Which
contains and handlers all the commands executed for drupal console.
Continue….
In our command class we should implement 2 functions, which will handle the
command Execution.
protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
Configure function defines the command, its description, arguments, and options.
We just need to override it by extending Command class.
Execute function define how the command will get executed, and what will be
input and output.
More drupal console commands
You can find more drupal console commands at drupalconsole.com cheatbook,
using below URL.
http://drupalconsole.com/cheatsheet/
Also, if we need help regarding any console command we can use below
command to get help and syntax.
Drupal help drupalconsole:command
Any Queries?
Thank you

More Related Content

Similar to Drupal 8 cli

Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
Acquia
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Acquia
 
Top 15 most popular drupal 8 modules
Top 15 most popular drupal 8 modulesTop 15 most popular drupal 8 modules
Top 15 most popular drupal 8 modules
Innoraft
 
[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
Srijan Technologies
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
Gerald Villorente
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Development
jcarrig
 
Faster and Smarter Development with Drupal Console
Faster and Smarter Development with Drupal ConsoleFaster and Smarter Development with Drupal Console
Faster and Smarter Development with Drupal Console
FFW
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
nuppla
 
Drupal
DrupalDrupal
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
valuebound
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
Lauren Roth
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
Rob Sawyer
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and Aegir
Iztok Smolic
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Luis Rodríguez Castromil
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
Hai Vo Hoang
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
Shabir Ahmad
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
Rachit Gupta
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
sparkfabrik
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
manugoel2003
 

Similar to Drupal 8 cli (20)

Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
 
Top 15 most popular drupal 8 modules
Top 15 most popular drupal 8 modulesTop 15 most popular drupal 8 modules
Top 15 most popular drupal 8 modules
 
[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
[Srijan Wednesday Webinars] Faster and Smarter Development with Drupal Console
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Development
 
Faster and Smarter Development with Drupal Console
Faster and Smarter Development with Drupal ConsoleFaster and Smarter Development with Drupal Console
Faster and Smarter Development with Drupal Console
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Drupal
DrupalDrupal
Drupal
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and Aegir
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 

Recently uploaded

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 

Recently uploaded (20)

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 

Drupal 8 cli

  • 1. Drupal 8 CLI Command line interface
  • 2. Recap 1. Introduction to drush and drupal console. 2. Comparison between drush and drupal console. 3. Drupal console installation. 4. How to use drush. 5. Scaffolding. 6. Tree structure using command. 7. Create virtual server using drush.
  • 3. Precap 1. What is Drupal Console? 2. Why Drupal Console? 3. How to use drupal console. 4. Generate a module. 5. Generate an entity. 6. Generate a profile. 7. Generate a theme. 8. Generate a custom command.
  • 4. What is drupal console? The Drupal Console is, at this time, a suite of tools that you run on a command line interface(CLI) to generate boilerplate code and interact with a Drupal 8 installation. Similar tools include: 1. Module Builder: Generate Drupal 6,7 or 8 module scaffolding. 2. Drupal Module Upgrader: Converts modules from Drupal 7 to Drupal 8, generated static help files with links to relevant change records. 3. Drupal 8 Tools: Drupal code generator written in bash. 4. Drush: Interact with Drupal installation via CLI, creates aliases, create custom
  • 5. Why Drupal Console? Drupal Console provides a number of commands for creating module scaffolding and boilerplate code. For any command, you will be asked a series of questions about what you want. In the case of module scaffolding, files are created and inside these files, classes—complete with namespacing and use statements—are created for you with the naming convention you specified in the command's prompts. The Drupal Console isn't a Drupal module, but was built with the Symfony Console Component and other libraries, such as Twig, to generate PHP, YAML, and other file types used in Drupal 8 module development. It is a tool designed for anyone using or planning to use Drupal 8. At the moment, it is used via a CLI, but there are plans to make it accessible through the Drupal administrative interface.
  • 6. How does Drupal Console differ from Drupal Module Upgrader? Drupal Module Upgrader takes a Drupal 7 module and attempts to port it to Drupal 8. While it generates files like Drupal Console does, Drupal Console generates module scaffolding and code based on a series of interactive prompts, instead of analyzing an existing module and converting it to work in Drupal 8.
  • 7. How does Drupal Console compare to Drush? There are many similarities between these two tools, but the main difference is how it was built, using an object-oriented architecture and Symfony components.
  • 8. Who is the intended audience for the Drupal Console? Any developer who will be responsible for writing custom code in Drupal 8. Any organization that will benefit from its vast potential. As such, the following groups in particular could find this tool advantageous to add to their learning Drupal 8 toolkit: 1. Enterprises and other organizations to reduce development time and reduce custom development risk factors. 2. Drupal 8 module maintainers and developers to speed up development and testing. 3. Drupal trainers and consultants providing Drupal 8 developer training.
  • 9. What features are planned for development? 1. Verbose code output for learning and leveraging docblocks 2. Complete config:import, site:status, and few a few other commands. 3. Import/export content between Drupal installations 4. Site Aliases 5. Generate dummy content, probably using PHP Faker library or Default Content project. 6. Add a GUI for Drupal Console as an alternative to the CLI. This could be especially useful for site builders wanting to generate dummy content or issue site commands without needing to use the command line. It could also be
  • 10. How to use drupal console? 1. You can install it using curl curl https://drupalconsole.com/installer -L -o drupal.phar 2. Using PHP in CLI php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar 3. Using Composer composer global require drupal/console:@stable
  • 11. Generate a module For generating a custom module we can use below command for a fresh drupal 8 custom module generation. Please note you must be in a drupal 8 project directory. drupal generate:module It will lead you to interactive CLI and will need some inputs from your side and generates the custom module.
  • 12. Generate an entity For generating a custom entity we can use below command for a fresh drupal 8 entity generation inside a custom module. Please note you must be in a drupal 8 project directory. drupal generate:entity:config It will lead you to interactive CLI and will need some inputs from your side and generates the custom entity along with its table. It also provides admin interface for managing the created entity(Asked on the CLI).
  • 13. Generate a profile For generating a custom profile we can use below command for a drupal 8 profile. Please note you must be in a drupal 8 project directory. drupal generate:profile It will lead you to interactive CLI and will need some inputs from your side and generates the profile and can be developed as distribution.
  • 14. Generate a Custom Command We can generate a custom drupal console command too. For generating a custom command we can use below command. Please note you must be in a drupal 8 project directory and it will ask you for a module where the new command can be inserted.. drupal generate:command It will lead you to interactive CLI and will need some inputs from your side and generates the command along with some example to show interactive feature.
  • 15. Introduction to command class As we are using symphony for drupal, it provides interaction with CLI using its console package command class which present at below path. vendor/symfony/console/Command/Command.php Drupal also inherited this class and generates its own class. All the drupal console commands generated using the above classes and can be available for CLI interaction.
  • 16. Command class structure and understanding If we want to generate a custom command, we should use below namespaces. use SymfonyComponentConsoleInputInputArgument; use SymfonyComponentConsoleInputInputInterface; use SymfonyComponentConsoleInputInputOption; use SymfonyComponentConsoleOutputOutputInterface; use DrupalConsoleCommandCommand; use DrupalConsoleStyleDrupalStyle; Also our custom class package must be extend Command base class. Which contains and handlers all the commands executed for drupal console.
  • 17. Continue…. In our command class we should implement 2 functions, which will handle the command Execution. protected function configure() protected function execute(InputInterface $input, OutputInterface $output) Configure function defines the command, its description, arguments, and options. We just need to override it by extending Command class. Execute function define how the command will get executed, and what will be input and output.
  • 18. More drupal console commands You can find more drupal console commands at drupalconsole.com cheatbook, using below URL. http://drupalconsole.com/cheatsheet/ Also, if we need help regarding any console command we can use below command to get help and syntax. Drupal help drupalconsole:command