Nov 06 2018
Nov 06

By Jesus Manuel OlivasHead of Products | November 06, 2018

By Jesus Manuel OlivasHead of Products | November 06, 2018

During this year and at several events SANDCamp, DrupalCamp LA, DrupalCon Nashville, and DrupalCamp Colorado I had a chance to talk and show how at WeKnow we approached the development of API driven applications. For all of you that use Drupal, this is something like decoupled or headless Drupal but without the Drupal part.

This article outlines weKnow’s approach and provides some insight into how we develop some web applications.

Yes, this may sound strange but whenever we need to build an application that is not content-centric, we use Symfony instead of Drupal; what are those cases? Whenever we do not require the out-of-the-box functionality that Drupal offers as content management, content revision workflow, field widgets/formatters, views, and managing data structure from the UI (content types).

Why we still use PHP.

We definitely knew the language pretty well, we have a large experience working with PHP, Drupal and Symfony and we decided to take advantage of that knowledge and use it to build API driven applications.

Why the API Platform.

This project is a REST and GraphQL framework that helps you to build modern API-driven projects. The project provides an API component that includes Symfony 4, Flex, and Doctrine ORM. It also provides you with client-side components and an Admin based on React and a Docker configuration ready to start up your project using one single command. Allowing you to take advantage of thousands of existing Symfony bundles and React components.

Wrapping up

Our developer's expertise within different technologies has given us the advantage to provide a great time to market while developing client projects. We also like sharing, if you want to see this session live, probably for the last time you should attend and join me at DrupalCamp Atlanta

Video from DrupalCon Nashville at the Youtube Drupal Association channel here:

[embedded content]

You can find the latest version of the slides from DrupalCampLA here 
 

Mar 07 2018
Mar 07

By Jesus Manuel OlivasHead of Products | March 07, 2018

By Jesus Manuel OlivasHead of Products | March 07, 2018

The Configuration Management (CM) system, is probably one of the most well known and exciting features of Drupal 8. But wouldn't it be even more awesome to be able to install a site, export configuration and then re-install site from scratch importing the previously exported configuration?

For those who are not yet clear on what we are talking about, this post is related to fixing the infamous exception error message when importing configuration:

"Site UUID in source storage does not match the target storage."

Why would you want to be able to install your site from an existing configuration?

A couple of big reasons come to mind:

  • Automate the creation of reproducible build/artifacts from scratch at any stage (Development, QA, Production) to test, launch or deploy your site.
  • Simplify onboarding for new developers to any project without the need to obtain a database-dump. Developers will be able spin-up sites from scratch just by installing the site and importing configuration files.

How to achieve this using Drupal Console?

Installing a site from a previously exported configuration using Drupal Console is as simple as 
updating your `console/config.yml` and append this configuration to the new overrides section. 

application:
...
  overrides:
    config:
      skip-validate-site-uuid: true

Executing the commands to install the site and import your previously exported configuration:

drupal site:install --force --no-interaction
drupal config:import --no-interaction

Simple and easy right? Well, this is possible using Drupal Console starting with the 1.7.0 version. This functionality is not supported by Drupal Core out-of-the-box. However, providing a better user experience while using Drupal 8 is one of the goals of Drupal Console and this is the reason we introduce features as the one we mentioned above.

What if my site does not have Drupal Console installed?

Download Drupal Console using composer in your site. if you do not have it already.

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

Create a Drupal Console configuration file for your site.

drupal init --site --no-interaction

What if my site is using an old version of Drupal Console?

Update per-site installation using composer:

composer update drupal/console --with-dependencies

Update the Launcher.

drupal self-update

Can I automate the execution of the site installation and import configuration commands?

Yes, using a chain command. A chain command is a custom command that helps you automate multiple command execution, allowing you to define and read an external YAML file containing the definition name, options, and arguments of multiple commands and execute that list based on the sequence defined in the file.

For more information about chain commands, refer to the Drupal Console documentation.

This is an example of a chain command to install a site and import a previously exported configuration.

command:
  name: build
  description: 'Build site by installing and importing configuration'
commands:
  # Install site
  - command: site:install
    options:
      force: true
    arguments:
      profile: standard
  # Import configurations
  - command: config:import
  # Rebuild cache
  - command: cache:rebuild
    arguments:
        cache: all

After adding this file, you can execute one command

drupal build

If you have any continuous integration or continuous deployment workflow you can integrate this command as part of that workflow.

Will this work with other modules like config_split?

Yes, you can use the config_split provided Drupal Console command. You should use the provided command to import the configuration and it will work as expected, without any issues or errors related to the uuid values.

drupal config_split:import --split=development --no-interaction

Note that you should replace `development` with the name you gave to your split.

Do I have other alternatives?

Yes, the other two well-known alternatives are:

Using config_suite module:

  • Create a new custom profile.
  • Add the drupal/config_suite dependency using composer.
  • Add the config_suite module to your custom profile and have it as a dependency on your profile_name.info.yml file.
  • Install the site using your new custom profile.
  • Export your site's configuration.

After following these steps, you will be able to reinstall your site using the custom profile and import the previously exported configuration.

Using the config_installer profile:

  • Install the site using your preferred contrib or custom profile.
  • Remove the `install_profile` key from your settings.php file.
  • Add patches to your composer.json file.
  • Add the drupal/config_installer dependency using composer.
  • Export your site's configuration.

After following these steps you will be able to reinstall your site. Note that you will be using the `config_installer` profile for any subsequent site installation, instead of the profile your site is currently using.

Read more about using `config_installer` profile:

Wrapping up

Feel free to update Drupal Console to latest 1.7.0 and try this new feature while is hot and provide feedback. Also, make sure you let us know which other UX/DX improvements you will like to see on the Drupal Console project.

Big or Complex Project,
Not Enough Devs?

We help development teams meet their deadlines by seamlessly integrating our highly skilled developers.

Feb 19 2018
Feb 19
Download and install Drupal 8.5 and try umami.

By Jesus Manuel OlivasHead of Products | February 19, 2018

By Jesus Manuel OlivasHead of Products | February 19, 2018

If you are following the upcoming release of Drupal 8.5 you might be aware of the umami profile. This installation profile is part of the Out of The Box experience initiative. The goal of this profile is to add sample content presented in a well-designed theme, displayed as a food magazine. Using recipes and feature articles this example site will make Drupal look much better right from the start and help evaluators explore core Drupal concepts like content types, fields, blocks, views, taxonomy, etc.

This profile is committed to the 8.5 branch of the Drupal project repository which makes it a little complicated to try out. To facilitate this I wrote a chain command.

You may think this looks cool but wait ... what this YAML means and what is a chain command?

A chain command is a custom command that helps you automate multiple command execution, allowing you to define and read an external YAML file containing the definition name, options, and arguments of multiple commands and execute that list based on the sequence defined in the file.

For more information about chain commands refer to the Drupal Console documentation.

How do I try this chain command?

In order to try this chain command it is required to have installed on your local system:

What do I need to do?

Copy the content of this gist file to a new file and name it as ~/.console/chain/try-umami-sqlite.yml

How do I execute the new command?

After adding the new file, the `try:umami:sqlite` command will be listed when running the list command. Then you have to execute the command on your local machine

Executing using the interactive mode and answering the interactive question:

drupal try:umami:sqlite

Enter the value for "directory" placeholder:

> /path/to/install/umami/

Executing the command inline and entering the directory where Drupal will be cloned and installed.

drupal try:umami:sqlite --directory=/path/to/install/umami/

Can I use another database as MariaDB, MySQL or other?

Yes, you can. But modifying the downloaded chain file will be required as updating the db-type='mysql' and passing the required options. To review all of the available options for the "site:install" command you can read the DrupalConsole documentation.

Dec 14 2017
Dec 14

By Jesus Manuel OlivasHead of Products | December 14, 2017

By Jesus Manuel OlivasHead of Products | December 14, 2017

It’s been a little over a year since weKnow came to life as a rebranding for Anexus, which allowed me to join the company as a new business partner. My main goal within the company is directing our efforts to explore new fields and technologies (that’s right, we are not just a Drupal shop anymore!)

As a web solution provider, having a website that accurately reflects what we do is a challenging task, because usually our plate is full with client work, and it’s not uncommon to put your own website at the end of the queue. This is why last year we decided to put together a basic landing page while setting aside some time to work on the company image as part of the rebranding.

Come 2017, we had the designs ready and started working on the architecture of the site, with the intention of taking advantage of the techniques, technologies, and lessons we learned while working on our clients’ projects, which led to the successful launch of our revamped site!

During the upcoming weeks, we plan to publish a series of blog posts in which we will explain the tools we used, the modules we selected, and the general reasoning that led to the approach we took. Some of the topics that we will discuss include: 

  • Component-Driven design using Pattern Lab.
  • Local development using Docker, Docker Compose, and Traefik.
  • Using Composer to manage project dependencies.
  • Site Configuration Management.
  • Content Synchronization.
  • Continuous Integration workflow and Continuous Deployments.

Stay tuned!
 

Mar 13 2017
Mar 13

By Jesus Manuel OlivasHead of Products | March 13, 2017

By Jesus Manuel OlivasHead of Products | March 13, 2017

I am currently working on a project where we are using DrupalVM as composer dependency.

Since ssh into the VM machine to execute commands could be a little cumbersome, and providing a site configuration file to take advantage of the --target option to execute commands remotely was not an option, because the generate commands can not be executed remotely if you want to use the interactive mode.

My options got narrowed to execute vagrant ssh and run commands within the VM (which I already mentioned I am not a big fan) or take advantage of the vagrant-exec plugin.

I decided to give a try to the vagrant-exec plugin and this what you need to do to use it in your project when DrupalVM is required via composer.

Install plugin

Execute plugin install command.

Plugin configuration

Create or update your config/Vagrantfile.local file with the following configuration:

Execute command using plugin

After this easy steps you can now execute DrupalConsole or any other shell commands against the VM without the need to shh into the machine.

Aug 09 2016
Aug 09

By Jesus Manuel OlivasHead of Products | August 09, 2016

By Jesus Manuel OlivasHead of Products | August 09, 2016

To make the DrupalConsole project more modular and easy to maintain, we are decoupling into separated projects.

As mentioned before the RC-1 release is close with a lot of changes. Stay in touch and feel free to ask any questions by commenting on this post or using the support gitter room https://gitter.im/hechoendrupal/DrupalConsole

Apr 24 2016
Apr 24

By Jesus Manuel OlivasHead of Products | April 24, 2016

By Jesus Manuel OlivasHead of Products | April 24, 2016

I published a quick reference guide (cheat sheet) for listing Drupal Console commands. The idea is to build an easy to use reference document, you can view it with modern desktop computer browser and mobile devices.

You can find this project at http://drupalconsole.com/cheatsheet/

The command information you can find on this cheat sheet is the same available commands at http://docs.drupalconsole.com/en/commands/available-commands.html documentation. In both projects, the information is exported from the main Drupal Console project and as you can expect the information within this cheat sheet is multilanguage.

You can fork this project to contribute from https://github.com/hechoendrupal/drupal-console-cheatsheet

NOTE: This project was based on the awesome project https://github.com/Aufree/laravel5-cheatsheet

Apr 21 2016
Apr 21

Drupal Console is the new CLI (Command Line Interface) for Drupal. This tool can help you to generate boilerplate code, as well as interact with, and debug Drupal 8. From the ground up, it is built to utilize the same modern PHP practices that have been adopted in Drupal 8.

Drupal Console takes advantage of the Symfony Console and other well-known third-party components like Twig, Guzzle, and Dependency Injection among others. By embracing those standard components, we’re fully participating in the PHP community, building bridges and encouraging the PHP community to join the Drupal project and allow us to reduce the isolation of Drupal.

Why is Drupal Console important?

Drupal is infamous for having a steep learning curve, complete with its own language of “Drupalisms”. While Drupal 8 simplifies and standardizes the development process, it is more technically advanced and complex than its predecessor. 

Managing the increasing complexity of Drupal 8 could be a daunting task for anyone. Drupal Console has been designed to help you manage that complexity, facilitating Drupal 8 adoption while making development and interaction more efficient and enjoyable. Drupal Console was created with one goal in mind: to allow individuals and teams to develop smarter and faster on Drupal 8. 

Drupal Console features

In this blog post, I will mention some of the most common features and commands of Drupal Console, to serve as a good introduction.

Install Drupal Console

Copy configuration files

The init command copy application configuration files to the user home directory. Modifying this configuration files is how the behavior of the application can be modified. 

drupal init

 

Validate system requirements

The check command will verify the system requirements and throw error messages if any required extension is missing.

Drupal check

Install Drupal 8

The easiest way to try Drupal 8 on your local machine is by executing the chain command and pass the option --file=~/.console/chain/quick-start.yml

The chain command helps you to automate command execution, allowing you to define an external YAML file containing the definition name, options, and arguments of several commands and execute that list based on the sequence defined in the file.

In this example, the chain command will download and install Drupal using SQLite, and finally, start the PHP's built- in server. Now you only need to open your browser and point it to 127.0.0.1:8088.

Drupal chain quickstart

 

Generate a module

The generate:module command helps you to:

  • Generate a new module, including a new directory named hello_world at modules/custom directory.
  • Creates a hello_world.info.yml file at modules/custom/hello_world directory.
Drupal generate module

 

Generate a service

The generate:service command helps you to: 

  • Generate a new service class and register it with the hello_world.services.yml file.
Drupal generate service

Generate a Controller

The generate:controller command helps you to:

  • Generate a new HelloController Class with a hello method at src/Controller directory.
  • Generate a route with a path to /hello/{name} at hello_world.routing.yml file.
Drupal generate controller

Generate a Configuration Form

The generate:form:config command helps you to:

  • Generate a SettingsForm.php class at src/Form directory,
  • Generate a route with path to /admin/config/hello_world/settings at hello_world.routing.yml
  • Register at the hello_world.links.menu.yml file the hello_world.settings_form route using system.admin_config_system as parent.

This command allows you to add a form structure to include form fields based on the field API. Also generates a buildForm and submitForm methods with the required code to store and retrieve form values from the configuration system.

NOTE: The parent route system.admin_config_system for the menu_link can be selected from the command interaction.

Drupal generate form config

 

Debug Services

The container:debug command displays the currently registered services for an application. Drupal contains several services registered out-of-the-box plus the services added by custom and contributed modules, for that reason I will use peco a simplistic interactive filtering tool to make this debug easier.

Drupal container debug

Debug Routes

The router:debug command displays the currently registered routes for an application. Similar to debugging services. In this example, I will use peco to make this debugging task easier.

Drupal router debug

Create Data

The create:nodes command creates dummy nodes for your application.

Drupal create nodes

Drupal Console provides a YAML to execute using the chain command. This file contains instructions to execute create:users, create:vocabularies, create:terms and create:nodes command using one command.

Change the application language

The settings:set command helps to change the application configuration in this example using the arguments language es we can set Spanish as the application language. After switching the default language the interface is translated.

Drupal generate controller

 

All of the available commands

The list command can be used to show all of the available commands. A print screen was not included because the more that 130 commands make the image huge to show on this blog post. 

For the full list of commands, you can also visit the documentation page at http://docs.drupalconsole.com/en/commands/available-commands.html 

What makes Drupal Console unique

  • Has been built to utilize the same modern PHP practices adopted by Drupal 8.
  • Generates the code and files required by Drupal 8 modules and components.
  • Facilitate Drupal 8 adoption while making development and interaction more efficient and enjoyable. 
  • Allow individuals and teams to develop smarter and faster on Drupal 8.
  • Help developers to understand Drupal 8 with the "--learning" flag.
  • Fully multilingual and translatable, just like Drupal 8 itself.

Links and resources

Feb 04 2016
Feb 04

By Jesus Manuel OlivasHead of Products | February 04, 2016

By Jesus Manuel OlivasHead of Products | February 04, 2016

I am planning to propose a session for DrupalCon New Orleans about Drupal 8 development and Drupal Console and currently looking for session name ideas.

Session abstract text:

Drupal is infamous for its learning curve and drupalisms but Drupal 8 simplifies and standardize the development process, unfortunately this comes with a cost. Drupal 8 is more technically advanced compared to its predecessor and managing the increasing complexity of Drupal 8 could be a daunting task. 

The Drupal Console is a CLI tool that helps you manage that complexity allowing you to generate boilerplate code, interact and debug Drupal 8.

The Drupal Console has been designed to increase productivity making Drupal development and interaction efficient and enjoyable.

Come along as we explore this tool that will help you developing by taking advantage of the modern PHP practices introduced into Drupal 8.

I have been used these names in the past for other DrupalCon events:

  • Introducing the Drupal 8 Console scaffolding module generator - Rejected at Austin.
  • Drupal 8 Console (scaffolding module generator) - Rejected at Amsterdam and accepted at Bogota
  • Speeding up Drupal 8 development using Drupal Console - Accepted at Los Angeles and rejected at Barcelona.
  • Faster and smarter development with Drupal Console - Rejected at Mumbai.

I am trying to figure which session name makes more sense:

  • Faster and Smarter Drupal 8 Development
  • Effective and efficient Drupal 8 Development.
  • Making Drupal development and interaction efficient and enjoyable.

Should I use Drupal Console as part of the session name?

  • Faster and Smarter Drupal 8 Development with Drupal Console.
  • Effective and efficient Drupal 8 Development with Drupal Console.
  • Debugging Drupal 8 with Drupal Console.

Should I add the Drupal Console session to Coding and Development, Symfony or PHP track?

As a Plan B, I will submit other sessions to increase my chance to speak at the event.

  • Writing CLI Commands for Drupal 8.
  • Debugging Drupal 8.
  • Writing a CLI Application using Symfony Components.

Feel free to add any thoughts related to the session abstract and name by commenting on this post.

Nov 26 2015
Nov 26

By Jesus Manuel OlivasHead of Products | November 26, 2015

By Jesus Manuel OlivasHead of Products | November 26, 2015

During past BADCamp sprints I was showing some of the latest DrupalConsole features to Mauricio Dinarte.

I was talking about the site:install command, at that time the command only supported MySQL and Mauricio asked several questions related to our plans and upcoming features, one of his questions was about supporting SQLite.

Few days after Mauricio published a blog post about that experience, you can read that post at Disposable Drupal installations with drush.

Two months later and after some work done by Omar Aguirre the SQLite support is now available and with some time on my hands I decide to provide a similar feature on DrupalConsole. The only missing piece was to start the PHP's built in server.

The server command has born.

This is a simple command that can receive an argument and this is an example how to use it.


# Run using default address argument value 127.0.0.1.8088
$ drupal server

# Passing address argument to use a different port number 
$ drupal server 127.0.0.1:8089

# Running default address argument using --root option to define the Drupal root. 
$ drupal --root=/Users/jmolivas/develop/drupal/sites/drupal8.dev server

Drupal Console server command

 

Putting all the pieces together

Once we have the only missing piece into the project I decided to take advantage of the DrupalConsole built-in feature to automate and execute several command and create this YAML file: ~/.console/chain/quick-start.yml


commands:
  - command: site:new
    arguments:
      site-name: drupal8.dev
      version: 8.0.0
  - command: site:install
    options:
        langcode: en
        db-type: sqlite
        db-file: sites/default/files/.ht.sqlite
        site-name: 'Drupal 8 Quick Start'
        site-mail: [email protected]
        account-name: admin
        account-mail: [email protected]
        account-pass: admin
    arguments:
        profile: standard
  - command: server

The previous configuration will execute several commands in this case command that will download Drupal, install it using SQLite and start PHP's built in server you only need to open your browser and point it to 127.0.0.1:8088.

This is how the execution looks like.

Drupal Console chain command quick start

As you can imagine you can take advantage of this to try Drupal 8 quick, use it on sprints, demos and trainings.

You can also make changes on the provided YAML file and add commands to download modules "module:download", install modules "module:install" , import configurations "config:import" and restore your database "database:restore" or any other command provided by DrupalConsole or a custom command by your own module(s).

The server command and the quick-start.yml file will be included on the next release, but if you want to try this feature now you can clone the project for instructions about getting the project you can visit the Getting the project documentation page.

May 07 2015
May 07

By Jesus Manuel OlivasHead of Products | May 07, 2015

By Jesus Manuel OlivasHead of Products | May 07, 2015

The Drupal Console is a suite of tools that you run on a command line interface (CLI) to generate boilerplate code and interact with a Drupal 8 installation.

This project takes the Symfony Console component and makes it available on Drupal 8.

The Drupal Console is another cool addition to the Proudly Found Elsewhere school of thought as it leverages the Symfony Console component to handle the CLI part.

A little history

Let’s move back in time to September 2013 at DrupalCamp Costa Rica, where this project was conceived. While David Flores and I were talking with Larry Garfield about Drupal 8. The introduction of Symfony Components had recently happened and at some point, Larry mentioned someone should bring the Symfony Console to Drupal 8.

That was the aha! moment. David and I had been discussing the same topic before, but had been procrastinating until that day when we decided to actually start working on the project.

During the first year of development the project it's been changing from a Drupal 8 module generator to a robust CLI tool for Drupal 8.

The project have commands that interact with the service container. This allows us to do administration task not related to code generation.

Why should you use it?

Managing the increasing complexity of Drupal 8 can be a daunting task for anyone, are you prepared for it?

The Drupal Console is a suite of tools to help you manage that complexity. 

What can you do with it?

  • Generate the code and files required by a Drupal 8 module:

    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 to generate. 

    Files are generated on the proper directory and inside these files, the proper code is generated for you. Classes area created adding namespaces, uses and also extends and implements keywords when required and adding services using Dependency Injection on class generation.
     

  • Interact with your Drupal installation:

    Drupal Console allows you to interact with your Drupal installation rebulding cache, rebuilding route system, listing/updating/exporting configurations.
     

  • Learning Drupal 8:
    Learn Drupal 8 by generate code using the "--learning" option.

Where can you find the project?

Do you like to know more about Drupal Console join enzo Eduardo García and myself at our DrupalCon Los Angeles session "Speeding up Drupal 8 development using Drupal Console", Thursday, May 14th, 1pm, Room 502B - Lullabot.

May 01 2015
May 01

By Jesus Manuel OlivasHead of Products | May 01, 2015

By Jesus Manuel OlivasHead of Products | May 01, 2015

I am exited to announce I will be speaking at a DrupalCon Los Angeles, I will be preseting Speeding up Drupal 8 development using Drupal Console on Thursday, May 14th, 1pm, Room 502B - Lullabot.

I will be joining enzo Eduardo García another project co-maintainer, together during this session we will be sharing the insights and latest achievements of the project and mentioning what features are planned for future development.

Drupal Console has been evolving a lot since project inception back in 2013 in DrupalCamp Costa Rica.

This projects started as a scaffolding tool, to generate the necessary code to build a Drupal 8 module, and evolved as a more mature CLI tool you can use it to interact with your Drupal 8 installation and can also be used to learn Drupal 8.

Managing the increasing complexity of Drupal 8 can be a daunting task for anyone, are you prepared for it? Drupal Console is a suite of tools to help manage that complexity. Come along as we explore this tool.

If you are involved with Drupal or looking forward to Drupal 8 you don’t want to miss this session.

NOTE: On Monday, May 11th, I will be leading the training Introduction to Symfony2: Getting Ready for D8 If you are attending to DrupalConLA and want to get exposed to writing code for Symfony 2 and Drupal 8 make sure you register for the class now.

Related links:

This is a cross blog post, you can find this at Blink Reaction 

Apr 27 2015
Apr 27

By Jesus Manuel OlivasHead of Products | April 27, 2015

By Jesus Manuel OlivasHead of Products | April 27, 2015

DrupalConsole is under heavy development and we are constantly adding new features based on project needs and user feedback.

One of the most recent feature is the capability for commands to call other commands.

The need for it became clear when we were executing commands like "generate:controller" and needed to execute another command by hand such as "router:rebuild" to rebuild the routing system. 

The initial idea was to chain command execution.  In order to do that in code you need to obtain the ChainCommandHelper and call the addCommand method passing the required arguments.

This is the added code to the "generate:controller" command:


$this->getHelper('chain')->addCommand('router:rebuild');

You can take a look at the class helper source code here ChainCommandHelper.php

This is the result of executing the "generate:controller"

As you can see below the generated/updated file list, two messages are showing the routing routing system was rebuilt.

The "chain" command

When that functionality was completed I had a discussion with the other project maintainers and we came up with the idea to create a command that could read a configuration file containing a queue and execute several commands based on the sequence defined in the configuration file.

We decide to use a standard YAML file extension and not go with something like chain extension because we did not want to add a new Drupalism to the project.

I will be recording a video in detail of how to take advantage of this command, in the meantime you can take a look a this demostration of how to use it: 

If interested you can see how the code looks like:

  • Command class source code at ChainCommand file.
  • YAML file containing the commands to be executed at chain.yml file.

How this command can help me?

You can create your own chain command and define the common Drupal 8 features you use while writing a Drupal 8 module and execute one command to have those features generated, as example:


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

NOTE: This a partial cross post from BlinkReaction site Drupal Console release 0.7.5

Feb 25 2015
Feb 25

After a great week in Bogota and some time to reflect I can say the first DrupalCon in Latin America was even better than I expected - yes it did feel more like a DrupalCamp than a DrupalCon - but it was still a great event! The quality of sessions were very good and as usual the greatest part was the chance to get together with a lot of friends from all over and especially Latin America.

Here are my highlights:

Training: 

Our Community Trainings - Intro to Symfony, Getting Ready for D8

After many difficulties and many delays securing a venue to provide free community trainings, I was able to present a 3 hour version of our “Introduction to Symfony2: Getting Ready for D8”.  I did this training Austin & Amsterdam with my colleagues from Blink Reaction and again at BADCamp with help from friends.

This time I received help from a co-maintainer of the Console project, David Flores. We had a packed room - people were sitting on the floor once no more seats were available. We received good feedback about the training and based on this session I can confirm that developers  are getting more and more interested in Drupal 8, Symfony and modern PHP frameworks but there are still so many who are not involved in the new PHP movement!

Visit the Drupalcon training page for more info on the other trainings:  https://latinamerica2015.drupal.org/event/community-trainings

For more information about this and other Drupal trainings visit www.blinkreaction.com/training and use our contact form or reach me on twitter at @jmolivas.

Keynotes:

Dries Buytaert

Maybe it’s me but the session was so similar to the one Dries presented at Austin - not that this was not good enough - but it did give me some deja vu - like I saw it before. Still a great keynote!

Session link: https://latinamerica2015.drupal.org/session/keynote-dries-buytaert

Larry Garfield aka Crell

“"

As usual Larry gave a great presentation. This time he included an awesome surprise - he plugged the Drupal Console project! Larry mentioned Console as part of a new pleasant experience working with Drupal 8 and new tools related to PIE (Proudly Found Elsewhere) - about using third party components. Thank you Larry!

Session link: https://latinamerica2015.drupal.org/session/keynote-larry-garfield

Our Sessions:

My Session - Drupal 8 Console (scaffolding module generator)

“"

I presented the DrupalCon session Drupal 8 Console (Scaffolding Module Generator). I was again accompanied by David Flores, one of the project maintainers. 

This session was almost a total refactor of the session I presented in 2014 at SANDCamp, NYC Camp, DrupalCamp Costa Rica, DrupalCamp LA & BADCamp. This time instead of just a live demo, I added videos to show command interaction, similar to what I did for the DrupalCon Amsterdam Lightning Talks. You can view it here at the session link: https://latinamerica2015.drupal.org/session/drupal-8-console-scaffolding...

Tess’s Session - Capture the (D8) Flag

Another session by fellow Blinker and travel partner Tess Flynn (@socketwench) was “Capture the (D8) Flag”. This is the second time I’ve had a chance to see Tess presenting and I can tell you she is one of my prefered speakers. Awesome content, awesome execution. And her presentation includes hand-drawn images!

Last year, when I saw the slides for the same presentation from TwinCities Drupal I forked the project and sent a couple of PRs (Pull Requests). You should too!

Session link: https://latinamerica2015.drupal.org/session/capture-d8-flag

Console and Flag featured in the Drupalize.me Guide to Drupal 8 at Bogata

Seeing both of these sessions featured in their blog post Guide to Drupal 8 at DrupalCon Bogotá the day before the event was super sweet! Thank you!

Other Sessions:

Headless Drupal is now "a thing"

Omar Aguirre presented Headless Drupal is now "a thing". He talked about Headless Drupal examples in D7 and D8. For D8 he demoed how to use the Drupal Console to help create a headless site - no surprise since Omar is a Console maintainer!

Session link: https://latinamerica2015.drupal.org/session/headless-drupal-now-thing

Drupal 8 CMI on Managed Workflow

Matt Cheney & Molly Byrnes presented an overview of the Configuration Management System in Drupal 8 and how you can take advantage of this new functionality in your daily workflow. Great session and something I plan on keeping a close eye on.

Session link: https://latinamerica2015.drupal.org/session/drupal-8-cmi-managed-workflow

#d8rules - Web-automation with Rules in Drupal 8

Josef Dabernig presented a great overview of the rules module in Drupal 8, sharing examples of code and how the project was crowdfunded using Kickstarter right through to the status of current project development. 

Session link: https://latinamerica2015.drupal.org/session/d8rules-web-automation-rules...

I recommend you view the session recordings of everything i described and visit https://latinamerica2015.drupal.org/schedule to see what else you might be interested in watching. I also highly recommend these two sessions I’ve seen previously:

Drupal in the Post-PHP-Renaissance World

https://latinamerica2015.drupal.org/session/drupal-post-php-renaissance-...

An Overview of the Drupal 8 Plugin System

https://latinamerica2015.drupal.org/session/overview-drupal-8-plugin-system

Sprints 

We held the first formal contribution sprint for the Console project! Our focus was on enabling people to learn how to contribute to the project and I’m very proud of what we accomplished. 

Four new contributors - thank you!

  • Renato Vasconcellos Gomes
  • Angel Hañari 
  • Lucas Mingarro
  • Emmanuel Cortes

Portuguese translations.

Two new commands

rest:disable - Disable a rest resource for the application.

site:mode - Switch system performance configuration.

For more information about my work and the Drupal Console see my blog posts on www.blinkreaction.com/drupal-experts-blog and visit these Drupal 8 Console links:

Next stop SandCamp and MidCamp. Hope to see you there!

Jan 24 2015
Jan 24

Drupal Console has been evolving a lot since project inception back in 2013 in DrupalCamp Costa Rica.

This projects started as a scaffolding tool, to generate the necessary code to build a Drupal 8 module, and evolved as a more advanced CLI tool you can use it to interact with your Drupal 8 installation, until last week, we used to describe the project as:

A suite of tools that you run on a command line interface (CLI) to generate boilerplate code and interact with a Drupal 8 installation.

But this project description it's already obsolete, because of two new features:

#1 Verbose code-output.

This new feature will generate code adding extra information to the generated code. Think about this as the commented messages you can find on the examples module code.

How to use it?

You just need to add the --learning option when executing a generator command.


$ drupal generate:controller --learning

As writing this blog post the only command that add a verbose output is the controller generator command generate:controller.

Yes as you just saw, the messages are multi-language, and as long as you change the language on your local configuration file and the message exist on the selected language a message on the selected language will rendered.

If you not see the message on your language, feel free to help us making this tool even better, by fixing current languages or adding more at: http://bit.ly/console-translations.

Why this feature was adedd?

Drupal 8 is more technically advanced compared to its predecessors, writing a module involves a lot of boilerplate code and we want to help developers generating that code. But we do not want them to think this is some sort of black magic.

We started Drupal Console as a side-project with the purpose of learn Drupal 8. And we wanted to provide this learning capabilities but we did not have an idea how to, until receiving a request about adding this feature.

Starting with the latest release 0.7.4 Drupal Console is not longer only a tool to generate code and interact with a Drupal installation.

Drupal Console will help developers to learn Drupal 8 adding messages on the generated code, those messages are in different languages, helping them to learn Drupal 8 on their own language.

#2 GUI web site

I will not provide too many details about this feature, other than Omar Aguirre @omers is currently working to provide a GIU web-site to execute generators and provide a downloadable file containing the generated code.

I will share a couple of images provided by Omar related to this feature.

Once we fully complete these two features, our goal to provide a tool easy to use for everyone even those users not comfortable using the CLI, will be closer to be completed.

For more information related to this project you can try the following links:

https://drupalize.me/blog/201502/podcast-no-58-drupal-console
https://www.lullabot.com/blog/podcasts/drupalizeme-podcast/58-drupal-console
http://jmolivas.com/slides/sandcamp2015/speeding-up-drupal-8-development-using-drupal-console/

If you want to hear about this project at upcoming events:

http://2015.midcamp.org/session-proposal/speeding-drupal-8-development-using-drupal-console
https://groups.drupal.org/node/458263

As usual feel free to comment on this post or ping me at @jmolivas or @drupalconsole letting know where do you want to see this messages adding extra information on the generated code when using the --learning option.

 

Jan 21 2015
Jan 21

You can read the first part one of this blog post at Blink Reaction blog site when it get released. For now you can read it at this blog at http://jmolivas.com/2014-a-year-of-contributions

This post was never think as two parts this just happened not sure why. Maybe the original one is taking too long to get published, and I saw and read the text too many times that I end up writing a second part.

2014 was a a year of changes and that was great for me. I started releasing code to an Open Source project the Drupal Console but what does that mean ?.

Releasing code to the public was hard for me. Everyone can see my code and they can see how bad I am as a developer and thus so they can see I suck. Well maybe I am just suffering from impostor syndrome or I am just a bad developer as I see my self.

Getting back in time I realize I did always suffer the same problem. I love music but I was never brave enough to create a band or record my songs, because I was always afraid to show what i created, just because people may said ... that sounds terrible.

The same happened to me related to release code, until one day I decide to contribute to and open source project. After a year I can see was not that bad, and at least some people think the project I am currently working at is useful.

Taking this experience as a catharsis. I decided to release some music this 2015 when and how not sure yet. But I think at some point between conferences and events this year I will invite friends, do some rehearsals, have fun and finally record a few song.

I am also planning to invite people contribute creating music remotly and I am currently looking for tools for remote music collaboration as https://www.ohmstudio.com and http://www.kompoz.com if you know any please let me know. 

I just hope I am not as bad guitar player as a developer, but that will not stop me this time.

Jan 21 2015
Jan 21

We're very pleased to announce that the new Drupal Console project is now multilingual!

We put a lot of hours into this effort because we felt it was so important to broaden the base of Console users and help them get off to a great start developing modules for Drupal 8. It will be the last major feature to be added before an upcoming code freeze that will allow us to work on Console documentation - another effort to broaden the base of users that can benefit from the project.

Here are a few reasons why we felt it was so important to add multilingual capabilities to the Console project:

  • Drupal is multilingual and Drupal 8 is even more so than ever. Take a look at D8MI at http://www.drupal8multilingual.org/  We want to ship this project with capabilities like these.
  • It feels good and more natural to use a tool on your mother tongue. Most of our project contributors are not native english speakers.
  • Separating messages from code will ease the text messages updates, no need to know/learn PHP or use an IDE to contribute.
  • David Flores & myself will be presenting a sesion in Spanish related to this project at the DrupalCon Latino in Bogota and we knew making the project multilingual would be interesting for the event audience.

As I mentioned on twitter:

Code looks a little hacky but got a translatable version of #Drupal Console commands, feature will be available on the next release. #drupal8

— Jesus Manuel Olivas (@jmolivas) January 2, 2015

But we needed a starting point.

Talking about code, this is what was required 

Adding the Symfony Translation Component to the composer.json file


"require": {
    ...
+   "symfony/config": "2.6.*",
+   "symfony/translation": "2.6.*",
    ...
},

For more information about the Translation Component look the awesome symfony documentation here.

Add translation files and messages


# extract of config/translations/console.en.yml
command:
  cache:
    rebuild:
      description: Rebuild and clear all site caches.
      options:
        cache: Only clean a specific cache.
      messages:
        welcome: Welcome to the cache:rebuild command.
        rebuild: Rebuilding cache(s), wait a moment please.
        completed: Done cleaning cache(s).
        invalid_cache: Cache "%s" is invalid.
      questions:
        cache: Select cache.

Actually four language files are available (en, es, fr and pt) you can find those files here, take note those files are only a copy of the console.en.yml file with few overrides for testing purposes.

Create a new Helper class

In order to take care of the translation the TranslatorHelper class was added see code here, the Helper was also registered at bin/conosle.php see code here

Inject the TranslatorHelper

For this task it was necessary to modify the RegisterCommandsHelper class, obtaining the TranslatorHelper and Injecting via the constructor when creating and registering a new instance of each command.


if ($cmd->getConstructor()->getNumberOfRequiredParameters()>0) {
  $translator = $this->getHelperSet()->get('translator');
  $command = $cmd->newInstance($translator);
}
else {
  $command = $cmd->newInstance();
}
$this->console->add($command);

You can see the full class here

How can you help

Feel free to take a look at the messages at the github repo and send us fixes.

How to override the default language

As simple as creating a new YAML file at your home directory ~/.console/config.yml and override the language value.


#file path ~/.console/config.yml
application:
  language: es

How to make a console.phar

We are using and recommend this great project http://box-project.org/


$ curl -LSs https://box-project.github.io/box2/installer.php | php
$ mv box.phar /usr/local/bin/box

// Run this inside your project directory to create a new console.phar file
$ box build

Feel free to try this new multilingual feature on the latest release v0.6.0, and as usual feel free to ask any questions commenting on this page, or adding a new issue on the drupal project page or the github repository.

I mentioned earlier that we are moving toward a code freeze so we can focus on documentation. The freeze is expected to be in place for about 4 weeks. I'll also use the time to prepare my DrupalCon Latino  Console presentation with David Flores aka @dmouse.

Stay tuned!

This post has been adapted from my personal blog.

Jan 20 2015
Jan 20

If you are following my blog post here, at http://www.blinkreaction.com/drupal-experts-blog, or if  you are reading my twitter timeline https://twitter.com/jmolivas, then you might have some questions about my role and how it works inside a Drupal agency like Blink Reaction.

You might ask, “does this guy do any client work?", "why is he always talking about this Console project?”.

When I was looking back on my contributions to the Drupal community for 2014, I found that my work can directly, at least somewhat, answer those questions.

First here’s why I am so excited about the Console project…

Drupal 8 is more advanced compared to its predecessor and writing a module involves a lot of boilerplate code, there are also a lot of things you need to know and do just to get started with building a new module and these can be repetitive and tedious therefore creating opportunities for errors.

Fortunately, a lot of that code can be generated automatically using a tool called the Drupal Console.

Drupal Console is a project that takes the Symfony Console component and makes it available on Drupal to automatically generate most of the new Drupal 8 module requirements.

This tool not only generates the module code, it also helps you interact with your Drupal installation.

The Drupal Console is another cool addition to the Proudly Found Elsewhere school of thought as it leverages the Symfony Console component to handle the CLI part.

A little history

Let’s move back in time to September 2013 at DrupalCamp Costa Rica, where this project was conceived. While David Flores and I were talking with Larry Garfield about Drupal 8. The introduction of Symfony Components had recently happened and at some point, Larry mentioned someone should bring the Symfony Console to Drupal 8.

That was the aha! moment. David and I had been discussing the same topic before, but had been procrastinating until that day when we decided to actually start working on the project.

At that time in 2013 and almost until the end of the second quarter of 2014, I was working as a Web Developer for the Office of Education in El Centro CA.

I was not doing any Drupal development there, mostly building Symfony2 applications, but since I do have a love-hate-love relationship with Drupal and never left it completely, I keep attending and presenting at conferences and working during my spare time on this Drupal Console as a side project.

Starting in 2014 I decided to send session proposals about the Console project and I had a chance to present at several Drupal Camps:

http://sandcamp.org
http://fldrupal.camp/
http://nyccamp.org/
http://drupalcamp.mx/
http://drupalcamp.cr/
http://2014.tcdrupal.org/
https://2014.drupalcampla.com/
https://2014.badcamp.net/

NYC Camp the one that brought the most changes for me in 2014.

A few weeks before the camp I sent an email to cancel my participation because I did not have any extra days-off at my job and also because flights and hotel costs add up quickly.

Then I got a call from Forest Mars and Molly Byrnes and they helped me make travel arrangements and found me place to stay with another fellow Drupal developer John Robert Wilson.

I’m so glad that everything worked out because the camp was awesome, I did my talk on the Console project, received great feedback and as always learned from fellow Drupalists who were present at the camp.

At that camp I had a chance to meet “Jeffrey A. jam McGuire” who invited me to participate and do my session at the Jam’s Virtual DrupalCamp. You can see the podcast here https://www.acquia.com/resources/podcasts/acquia-podcast-156-j-m-olivas-introducing-drupal-8-console-scaffolding-module-generator

Also at that Camp I had the chance to talk with John DeSalvo and Ray Saltini about Blink Reaction, the Blink Institute and their plans with Symfony and Drupal 8. It turned out those plans fit perfectly with what I was looking for in order to continue my work in the Drupal community. They are giving me that chance by spending time working on Drupal 8 projects.

After almost a month of communication and the interview process I got hired.

What about contributions

Since my main role at Blink Reaction is to contribute back to the community after some talks we agree that I should spend time working on the Drupal Console my side project now became my main activity and also I will get paid for do what I was doing as a hobby.

So far the project is been pretty active as you can see https://www.drupal.org/project/console

While working on the console project I have found and fixed (so far) two Drupal 8 core bugs I did a blog entry related to this topic  http://www.blinkreaction.com/blog/two-drupal-8-core-bugs-found-and-fixed

Also while attending TC Drupal, I had a chance to work with Cathy aka @YesCT and sent patches to another two issues and got the accepted, so far I do have 4 contributions to Drupal 8 Core as you can see on this site http://www.drupalcores.com/. I know just 4 not a big deal right but working on Drupal Core Issues and the contribute space in Drupal is kinda tricky.

What was accomplished for the Drupal Console during 2014.

During the first year of development the project it's been changing from a Drupal 8 module generator to a robust CLI tool for Drupal 8.

The project now have commands that interact with the service container. This allows us to do administration task not related to code generation as listing routes and services from the container and clear Drupal caches.

Keep the project in sync with Drupal 8 changes.

During the development of the console the project have been in synchronization with the development branch of Drupal 8.

This make sense at the beginning of the project when Drupal 8 was in Alpha state.

Since DrupalCon Amsterdam Drupal Beta 01 version has been released for testing and feedback and after some discussion with David Flores the other co-maintainer of the project we decide to keep the project in synchronization with Drupal Beta releases.

More information and full blog post http://jmolivas.com/the-drupal-8-console-will-sync-drupal-8-beta-releases

Provide an installer and executable phar file.

One of the most recurring questions since project started is why is the installation process modifying the composer.json & composer.lock file, or why is the installer adding new libraries to "core/vendor" directory, because you know that is considered hacking the core.

More information and full blog post http://jmolivas.com/try-the-new-drupal-console-installer-and-executable-phar-file

Install Drupal Console globally.

This change provide the feature of accessing the console.phar from anywhere on your system, using a global installation as composer or drush does.

I will list a few points why this new global executable is important for the life cycle and roadmap of the Drupal Console project:

* Add a new self-update command to make easy update to new releases
* Work on the documentation, since installation process will probably not change
* Add a new set of command like site:install
* Take advantage of site aliases
* Work on the issue related to Integrate console with drush
* Add console commands to wrap drush commands

More information and full blog post:
http://jmolivas.com/install-drupal-console-globally

DrupalCon Amsterdam 2014 Drupal Lightning Talk presentation

For the first time ever DrupalCon Amsterdam replaced the third day keynote with lightning talks in the main auditorium. I sent my proposal in and was lucky to be selected. I shared details about the project I have been more involved in lately The Drupal 8 Console. Take a look at my presentation slides here. If you have any other questions on this project, let me know!

Check out the reactions on Twitter related to this presentation here: Storify - Drupal 8 Console DrupalCon Amsterdam Lightning Talk

I've also put together a list of blog posts and other reactions about this project: https://gist.github.com/jmolivas/3c12bc53708fdadfa3f7

NOTE: This is a cross-blog-post that will be published at Blink Reaction web site.

Jan 14 2015
Jan 14

A new release was published today v0.6.2 this new release include bug fixes and new features that I will mention in this blog post.

Support for new field types on form generation

Add support for select, radio, textarea & checkbox fields in form generator. Thanks to Eduardo García aka @enzo for this feature.  

Add multilingual support for generated module commands

Since Drupal modules already have a config directory, the decision to store custom module command translations was adding a new directory and file at that path as example:


my_module\config\translation\console.en.yml # for english 
my_module\config\translation\console.es.yml # for spanish 

Self update command

This command update a phar install with the latest version. Thanks to David Flores aka @dmose for this feature.


$ drupal self-update

Plugin REST resource generator

This command generates a new plugin resource class. Thanks to Eduardo García aka @enzo for this feature.  


$ drupal generate:plugin:rest:resource

How to used the new generated REST resource 

1. Download and Enable Rest UI module https://www.drupal.org/project/restui (git version)
2. Enable resource at http://example.com/admin/config/services/rest select format and authentication provider
3. Enable the Rest Resource permission to access by role at http://example.com/admin/people/permissions

If you need more information about this topic, I receomend you to read this blog post from enzo http://enzolutions.com/articles/2014/12/16/how-to-create-a-rest-resource-in-drupal-8/

New place for documentation

We moved the Drupal Console documentation to gitbook http://hechoendrupal.gitbooks.io/drupal-console/ 

Feel free to fork and contribute at the ducumentation repository at github https://github.com/hechoendrupal/drupal-console-book

Dec 18 2014
Dec 18

You may have heard and read a lot about Drupal 8 lately, without much support to go along with it. Well here at Blink Reaction, we are working on changing that and contributing as much help as we can to the community with the issues that we’ve come across so far in Drupal 8. In this post I will show you how you can try Drupal 8 by installing dependencies such as composer and drush so you can have a Drupal 8 site running on your local machine.

Disclaimer:

For this blog post I will be using Mac OS X Yosemite which is the OS I have on my development machine.

To follow this walkthrough you should have an *AMP stack installed and working on your machine. If you don’t already have an environment, here are some options: 

* Mac: Acquia Dev DesktopMAMP or php-osx
* Windows: XAMPPWAMP or Ampps
* Linux: Install with your package manager or Ampps
* Use a Virtual Machine

Whichever environment you choose, make sure you have the following:

* PHP 5.4.5 or higher (very important!)
* A MySQL server that is configured to work with PHP

Download and Install Composer

Composer is a dependency management library for PHP. Follow the instructions from the composer website at https://getcomposer.org/download. You can download it anywhere onto your local computer. 

Then, if you have curl installed:

$ curl -sS https://getcomposer.org/installer | php?

Or if you don't have curl installed:

$ php -r "readfile('https://getcomposer.org/installer');" | php

Accessing composer from anywhere on your system:

To access composer globally move the executable 'composer.phar' to a directory that is already in your PATH.

$ chmod +x composer.phar
$ mv composer.phar /usr/local/bin/composer

Download Drush

Clone the drush git repository in a directory that is outside of your web root.

$ cd /usr/share
$ sudo git clone --branch master https://github.com/drush-ops/drush.git

Install Drush

From the drush root directory, run composer to fetch the required dependencies.

$ cd /usr/share/drush
$ sudo composer install

Accessing Drush from anywhere on your system.

Create a symbolic link to the Drush executable in a directory that is already in your PATH.

$ ln -s /usr/share/drush/drush /usr/bin/drush

Download Drupal

At the time of writing this blog post the latest release of Drupal is 8.0.0-beta3. In order to download Drupal 8 we will use drush dl command an alias for drush pm-download.

$ drush dl drupal-8.0.0-beta3
$ mv drupal-8.0.0-beta3 drupal8.dev

Install Drupal

Change to the directory where Drupal was downloaded by drush and use drush si command as an alias for drush site-install.

$ cd path/to/drupal8.dev/
$ drush si standard --db-url=mysql://root:[email protected]/drupal --site-name=drupal8.dev --account-name=admin --account-pass=admin --account-mail=[email protected] -y

Make sure you use your own user and database credentials when running drush si and never user root on production. In this example we are accepting any interaction - answering yes when passing -y argument.

As you can see, when using Drush the process is very similar to previous Drupal versions - drush dl & drush si.

Finally, if you want to access your Drupal 8 site using http://drupal8.dev you will have to:

Add a new host in your hosts file (‘/etc/hosts’ as I am using Mac OS X)

127.0.0.1 drupal8.dev

Add a new virtual host in our web server config. Apache, in my case.

<VirtualHost *:80>
   ServerAdmin jesus.o[email protected]
   DocumentRoot "/path/to/drupal8.dev"
   ServerName drupal8.dev
   <Directory "/path/to/drupal8.dev">
       Options FollowSymLinks
       AllowOverride All
       Require all granted
   </Directory>
</VirtualHost>

References:

* Composer: A dependency manager for PHP - https://getcomposer.org/
* Drush GitHub repository - https://github.com/drush-ops/drush
* Drupal project page - https://www.drupal.org/project/drupal
* Detailed information about drush commands -http://www.drushcommands.com

Note:

If you want to try Drupal 8 now. without worrying about configuring your local environment you may use the following online services:

https://insight.acquia.com/free?distro=drupal8
http://getpantheon.com/d8 
http://trydrupal8.com/ 
http://simplytest.me/

Have questions? You can catch me on Twitter @jmolivas. Stay tuned for more helpful posts on Drupal 8.

Blink Reaction sponsors the Console project for developing in Drupal 8.  

Visit http://www.drupal.org/project/console to try it. Please feel free to submit issues and requests!

Oct 30 2014
Oct 30

While working on the console project I have found (so far) two Drupal 8 core bugs. In this blog post I will explain how I found these bugs and what I have done to fix them.

First bug - Wrong service definition

I found the first one when adding a command for debugging registered services within the container.

Using the console command:

$ bin/console container:debug

Problem

The service definition for “controller.entityform” on "core/core.services.yml" file was wrong. The configured arguments injected are not expected for the class when creating a new instance of the object.

The "core.services.yml" is where all Drupal core services are defined.

Current declaration:

 controller.entityform:
class: Drupal\Core\Entity\HtmlEntityFormController
arguments: ['@class_resolver', '@controller_resolver',
'@service_container', '@entity.manager']

More information about which services are registered on Drupal 8: https://api.drupal.org/api/drupal/core!core.services.yml/8

How to reproduce:

$this->getContainer()->get($serviceId);

The line of code used to reproduce the error is part of the console project. As you can see it is in the project repository. https://github.com/hechoendrupal/DrupalAppConsole/blob/0.2.15/src/Comman...

The get($id) method returns the object associated service form the container. Using the $id parameter as the service identifier. You can see the code on the Symfony Dependency Injection Component repository: https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/Depend...

The following error was given:

Recoverable fatal error: Argument 1 passed to Drupal\Core\Entity\HtmlEntityFormController::__construct() must implement interface Drupal\Core\Controller\ControllerResolverInterface, instance of Drupal\Core\DependencyInjection\ClassResolver given in Drupal\Core\Entity\HtmlEntityFormController->__construct() (line 39 of core/lib/Drupal/Core/Entity/HtmlEntityFormController.php).

Proposed resolution

Inject the proper arguments on the service definition. Based on the API documentation for the class HtmlEntityFormController: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

Service declaration should look like this:

  controller.entityform:
    class: Drupal\Core\Entity\HtmlEntityFormController
    arguments: ['@controller_resolver', '@entity.manager', '@form_builder', NULL]

Even when the final resolution was to remove the service definition for “controller.entityform”. Running the console command helped me find this bug in Drupal 8 core and have it fixed.

More information on the issue page:
- Name: Remove service definition for controller.entityform from core/core.services.yml
- Link: https://www.drupal.org/node/2303823 - Closed (fixed)

Second Bug - Invalid Composer version

I found this bug when installing the Console project

$ COMPOSER_BIN_DIR=bin composer require --dev drupal/console:@stable

Problem

I was not able to complete the installation because the PHP version required on "composer.json" file was not valid.

Current declaration:

require": { 
"php": ">5.4.4-13",

How to reproduce:

A) Running the installation process of Console project, but not everyone is using the console project, even when Larry Garfield AKA @Crell recommended it on Twitter after seeing my Drupal 8 Console Lightning Talk at DrupalCon Amsterdam.

The D8 console from @jmolivas looks even better than before! Every D8 developer should use it. #DrupalCon

— Larry Garfield (@Crell) October 2, 2014

B) Validate a composer file running the composer validate command. The composer documentation also recommends using this command.

“You should always run the validate command before you commit your composer.json file, and before you tag a release. It will check if your composer.json is valid.” https://getcomposer.org/doc/03-cli.md#validate

$ composer validate

After running the validate command, the following error was given:

./composer.json is invalid, the following errors/warnings were found: require.php : invalid version constraint (Could not parse version constraint >5.4.4-13: Invalid version string "5.4.4-13")

Proposed resolution

Drupal 8 requires PHP 5.4.5 at least, the recommendation was to update the "composer.json" file as follows:

require": {
"php": ">=5.4.5",

This time the patch was accepted and the bug was fixed.

More information on the issue page:
- Name: Composer require.php : invalid version constraint
- Link: https://www.drupal.org/node/2354301 - Fixed

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web