After three months of hard work, mostly at night and during the weekends, we finally launched the first minimal viable version of VideoDrupal.org (beta 1.0), a curated mashup of Drupal video tutorials published on Youtube to make them more accessible for personal, educational and professional purposes.
In this post we’ll see how to save temporarily values from a form and how to retrieve or process them later in a controller. To do that, we’ll use the Form API and the private tempstore (the temporary store storage system of Drupal 8).
It’s not easy to create a list of the most useful Drupal 8 modules because it really depends on the site you will create or manage. But there are some really helpful modules that you can use in almost all cases.
In this post, I will share a list of modules that I use on almost all my Drupal 8 projects. They aren’t specifically for a particular type of site, but I find that they are always helpful, both in development and production environments.
Batch processing is usually an important aspect of any Drupal project and even more when we need to process huge amounts of data.
The main advantage of using batch is that it allows large amounts of data to be processed into small chunks or page requests that run without any manual intervention. Rather than use a single page load to process lots of data, the batch API allows the data to be processed as number of small page requests.
Using batch processing, we divide a large process into small pieces, each one of them executed as a separate page request, thereby avoiding stress on the server. This means that we can easily process 10,000 items without using up all of the server resources in a single page load.
Queues are particularly important when we need to stash some tasks for later processing. To do so, we are going to put some tasks or data in a queue (create the queue) and later we will process those tasks with a QueueWorker plugin (process the queue), usually triggered by cron.
There are several ways to create a queue:
- With a form class
- With a controller class
- With a hook_cron() function
To process the queue, we also have different options:
- As a cron process with a QueueWorker plugin
- As a batch process also with QueueWorker plugin but extending a base plugin
- As a batch process claiming each item of the queue in a service or in a controller
Creating forms is part of the day to day live of a Drupal programmer. Forms are represented as nested arrays in both Drupal 7 and Drupal 8. But they are different in that in Drupal 7 you define your form arrays in functions and in Drupal 8 you create a form class.
In this post we’ll create a custom form with two fields, a text field and a checkbox field, we’ll validate those fields, display them in a message and finally redirect the user to the home page.
In Drupal 7, to manage system variables, we used variable_get() / variable_set() / variable_del() calls and stored those variables in the variable table of the database.
In Drupal 8 we now use the Configuration system which provides a central place for modules to store configuration data. This system allows to store information that can be synchronized between development and production sites. This information is often created during site building and is not typically generated by regular users during normal site operation.
In Drupal 8 configuration is still stored in the database, but it can now be synced with YML files on the disk for deployment purposes aswell.
Runing composer install or composer update on your Drupal 8 installation to install or update modules and themes could be sometimes frustrating because it can be very slow. Too slow in fact. But it doesn't have to be that way. Here are some tips to speed your Composer working with Drupal.
Prestismo is a global composer plugin that that enables parallel installations and it's very fast! It can be more than 2x faster. But Prestissimo requires cURL, which may not work behind certain firewalls or proxies.
Today composer is the recommended approach to install (o more precisely to download) Drupal 8. This is true for the core but also for contributed modules and themes.
So now, to start a new Drupal 8 project, we need to download it via composer and not as we did before with drush or drupal console. Of course, we'll still use drush or drupal console to install contrib modules or themes, but not for downloading them.
The main benefit of using composer is that it allows us to systematically manage a sprawling list of dependencies (and their subsidiary dependencies) and ensure that the right versions for each package are used or updated.