Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

4 useful tools you should know before starting your first Drupal 8 project

Parent Feed: 

Are you thinking to start developing with Drupal 8?

This blog post is the third (and last) one of a series, where we want to share our experiences developing with Drupal 8 after having faced our first real project with it. In previous blog posts we have talked about some recommendations and documentation resources that will help you master the Drupal 8 learning curve. In this article, we will take a look at some tools that will make your life as a developer easier by saving time and avoiding common errors. Let’s get started!

Drupal Console

Drupal Console is a suite of tools that runs on a command line interface to generate boilerplate code and interact with Drupal 8. Using the Drupal console you will drastically increase your development speed, for sure! It’s very easy to use: Each command is guided and helps you to set the proper parameters for every command you run. It provides a big list of commands that are very useful in your daily work with Drupal. Some of them are:

Other Drupal Console features that we find interesting are:

What’s more, Drupal Console will not only allow you to save time (which means money) but also to learn how some of the components you can build in Drupal are implemented. For instance, when you generate a new content entity for your project, you can check the generated code and learn how it is built. From my point of view, using the Drupal Console is a must if you are going to face a Drupal 8 project. Your team will definitely save time by avoiding typos as well as other common and minor errors when developing custom modules in your projects.

Join the community

The chief maintainers of the project are doing a great job but any help is always welcome. As developers, who use an open source software it is our duty to contribute to the software we use in our projects and help to improve its quality. As a Drupal agency, Cocomore has worked on this great project with some issues and new features like:

Our experience working on the project was very pleasant, partially due to quick feedback from the maintainers and other users. Don’t wait any longer, head over to the project to contribute, check the issue queue and work with it. You will learn a lot and at the same time you will contribute to the project!

XDebug

If you are going to face a Drupal 8 project, it is crucial to start using XDebug in your local environment. Xdebug is an extension of PHP, which provides debugging and profiling capabilities. It will help you debug your PHP code step by step. This will allow you to have more information about the context, the trace of the thread, etc. Within it, you will be able to find out where errors of your project are located in your code and you will be able to fix them much faster than using other debugging techniques. Most of the IDEs like PHPStorm or NetBeans have extensions for using XDebug and provide a UI for debugging your project with it. Additionally, there are several plugins and extensions for most common browsers like XDebug Helper for Chrome. Those plugins or extensions will help you set up the configuration needed to start debugging a page in the browser.

In this blog post I will not go into detail about how to install XDebug. If you use PHPStorm, you will find helpful information in the official documentation from Jetbrains.

Tuning your services.yml and settings.php files

Another tool you will love when working with Drupal 8 is the debug tool provided by Twig Engine. Since Twig was introduced as the new template engine for Drupal 8, developers are able to use its debugging tool. The Drupal 8 implementation adds information about:

This information is quite helpful because you will, for instance, be able to know which template you can overwrite to customize the output in your project. This was not possible in previous versions where you had to remember, what the pattern was for overwriting the template you needed to customize. Additionally, there are other development configurations which you are probably interested in, for example Debugging compiled templates.

How Can I debug my templates?

Twig provides some debugging functions like dump(), which prints the value of the given variable. But if you miss using XDebug within the Twig templates, you are lucky because you can use the Twig XDebug module. It provides a new twig function breakpoint() according to the module description:

The breakpoint will open in a file (BreakpointExtension.php) outside your Twig template, but you'll be able to inspect any variables available at the breakpoint in the template.

You will be in charge of your templates again!

Web Profiler

If you were using the Web Profiler module in previous versions of Drupal, you have to know that it has been merged into the Devel module as a submodule in Drupal 8. Web Profiler is a bundle of the Symfony Console for Drupal 8. It provides a toolbar at the bottom of the page where admins can check important information for profiling your websites. You will be able to check the database queries run, the cache effectiveness, views and much more. It was particularly helpful for us to check the database queries run when a certain page was requested and to filter them. If you want to learn more about the features provided by this module, you can check the article Web Profiler in Drupal 8 by Joe Fender from Drupalize.me where you can find a detailed list of the features provided by this module.

Keep reading

Like we said at the beginning, this blog post is the third (and last) of a series we wrote about recommendations and thoughts that might be helpful if you are thinking about starting your first Drupal 8 project. We hope that you will enjoy developing your Drupal 8 project as much as we have with our favorite CMS. Thanks for reading and sharing.

Original Post: 

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