20

Drupal console is a Drupal CLI tool, from the-ground-up, that leverages Symfony CLI components and modern PHP OOP design practices. Drush is a venerable Drupal CLI tool that has been around since Drupal 4.7, thus built with an older design practice. However, since Drush 9 it's been rearchitected to use the Symfony components as well. There is overlap based ...


12

With Drush: drush php-eval 'node_access_rebuild();' With Drupal Console: drupal node:access:rebuild Which is of course similar to Chamil's answer, but accessible and copy pastable :)


9

You should follow the docs on the official Drupal Console repo on how to install it with Composer. Note that the global launcher is not recommended, it is recommended to add it to your project through Composer. https://github.com/hechoendrupal/drupal-console/blob/master/README.md # Change directory to Drupal site cd /path/to/drupal8.dev # Download ...


7

Run shell commands via the Process class available in the Symfony framework. From the Symfony docs: use Symfony\Component\Process\Process; use Symfony\Component\Process\Exception\ProcessFailedException; $process = new Process('ls -lsa'); $process->run(); // executes after the command finishes if (!$process->isSuccessful()) { throw new ...


6

If you're having issues with Drupal Console, you don't have access to it, or you're not using Drush, you can also do it via the UI. Login as an administrator Visit /admin/reports/status (also located via the menu at Reports->Status report Find the Node access permissions section Click on the Rebuild Permissions link (which is also located on /admin/reports/...


6

In Drupal 8, you cannot anymore disable modules: You can just install or uninstall them. Uninstalling a module has the same effect it had on Drupal 7 and previous versions: It removes the database tables the module installed. On /admin/modules, Drupal shows you which modules are not installed, and which modules are installed. You can click the checkbox ...


6

Turns out it can be done with the config:export:entity command. drupal config:export:entity paragraphs_type [PARAGRAPH_TYPE] --module="[YOUR_MODULE]" --optional-config --remove-uuid --remove-config-hash --include-module-dependencies


5

You can do this using the following hooks in your module. hook_user_login hook_user_register (In D7 we had user_insert hook.) Examples: User Login Hook: function mymodule_user_login($account){ //your code here } User Register Hook: function mymodule_user_insert(Drupal\Core\Entity\EntityInterface $entity){ //your code here }


5

This will surely help you debug: https://evolvingweb.ca/drupal-console-windows-devdesktop-troubleshooting And here is a guide explaining how to do it from scratch: https://evolvingweb.ca/blog/installing-drupal-console-windows


5

You need to edit the entity class's annotation, at e.g. module_name/src/Entity/FooEntity.php. This is an example of what you need from the Node entity class: links = { "canonical" = "/node/{node}", "delete-form" = "/node/{node}/delete", "edit-form" = "/node/{node}/edit", "version-history" = "/node/{node}/revisions", "revision" = "/node/{...


5

The option exists in Drupal Console's drupal generate:theme; it's done by specifying the --base-theme option in the command. The option's value adds the base theme key with option's value into the generated theme's .info.yml file (which make the new theme a sub theme).


4

That option will add some code to the generated module to make it a Feature module - a module that provides some exportable configuration. More info: https://www.drupal.org/docs/8/modules/features/creating-and-configuring-bundles Source: https://github.com/hechoendrupal/drupal-console/blob/master/src/Generator/ModuleGenerator.php#L94


4

As Berdir said, as long as https://www.drupal.org/node/2429699 is not ready, you need to provide your own Views Filter plugin. I created this plugin, based on TaxonomyIndexTid, for Nodes, see https://gist.github.com/StryKaizer/ae1cb9abc4844a9e7ac12317a9d84a78 You need to place this file in a custom module at yourmodule/src/Plugin/views/filter/NodeIndexNid....


4

With Drupal Console: $ drupal debug:plugin migrate.destination Or short: $ drupal dpl migrate.destination gives: ------------------------------------------ --------------------------------------------------------------------------------------- Plugin ID Plugin class ...


3

There is no such thing as modules/contrib or modules/custom with the vanilla download of Drupal. It is a convention you can use for organization. Create the folders yourself. Drupal will still find the modules in either one. The same principle applies to the themes folder. Some modules that say "download the JS plugin to /libraries" - you would have to ...


3

So the problem was that Drupal console's dependent packages (drupal/console-core, drupal/console-en) didn't use the minimum-stability option that I specified via @, so I just had to set it globally and run again: $ composer global config minimum-stability rc $ composer global require drupal/console:1.*


3

You could use some Drupal Console export commands for this: config:export:content:type config:export:view You could use the --module option to specificy which module to export. It's easier to use the Features module though. From the project page: A feature is a collection of Drupal entities which taken together satisfy a certain use-case. ...


3

Specifying the root resolved this for me. Having used composer to install drupal through drupal-composer/drupal-project the site is put in a "web" folder so the following worked. drupal --root=/var/www/html/web list I had also run the init command beforehand drupal --root=/var/www/html/web init


3

As suggested by elstevenson, I used the validation API. Here the steps. Create a repository in your module repo. /src/Plugin/Validation/Constraint Create a constraint (name = Unique) namespace Drupal\module_name\Plugin\Validation\Constraint; use Symfony\Component\Validator\Constraint; /** * @Constraint( * id = "Unique", * label = @Translation("...


3

Sean Hamlin - 10 things I learnt building in Drupal 8 Drupal Console is awesome Every time you need to generate a custom module, or a new block in a custom module, you can quickly and easily use Drupal Console to produce the code scaffolding for you. This quite easily makes the job of a developer a lot less stressful, and allows you to ...


3

With the term "field type" you probably don't find what you are looking for. Better search for "form and render elements". You can find a list of all available elements here: https://api.drupal.org/api/drupal/elements/8.2.x You can use all elements of the type "FormElement".


3

The third question asked when you run drush generate theme is "Base Theme [classy]" You can specify the machine name of the parent theme there.


3

I think I found the answer myself: drupal config:delete active block.block.my_block (For my specific case) Good luck finding the configuration name. There's no listing from the console. I had to export the whole damn thing to a directory and grep for it.


3

drush pm:security should be fine in listing Drupal modules with security updates. There was a bug from the drupal-composer/drupal-security-advisories project that resulted in not listing the forms_steps module and some other modules. It was promptly fixed and now it works!


3

Drupal Console is not a Drupal module, is a shell for Drupal that is installed as a Composer package. This means it is not installed in Drupal so you don't have to uninstall it. To remove it simply use composer and update your dependencies: composer remove drupal/console composer install Update You may also need to remove the Drupal Console Launcher if you ...


2

Here is the solution I found for my problem: Let say that my entity is named Entity. I created a new operation in my controller implementing my business logic , say we'll call it operation_name. Then, in my EntityListBuilder.php , I surcharged the operation getDefaultOperations, specifying the name of my operation, the url and title : public function ...


2

a mapping must be done in sites/sites.php for drupal multisite:debug to display the list sites.php /** * Multi-site directory aliasing: * * Edit the lines below to define directory aliases. Remove the leading hash * signs to enable. */ $sites = array ( 'my_domain_name.fr'=>'my_folder_name_in_sites?' ); i am not sure for it to be ...


2

Install and configure Features module. Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. To export using terminal use Drush. Drush commands for features : https://drushcommands.com/drush-7x/features/features-add/


2

Try using the PHP functions exec() or shell_exec().


2

I'm facing the fact of I should write Drush Commands or Drupal Console Commands, but in my case I need to maintain the same module in Drupal 8 and Drupal 7. As you know we don't have Drupal Console in Drupal 7, so in this case if I create Drupal Console Commands I don't will have this commands available in my Drupal 7 module. But if I use Drush Commands I ...


Only top voted, non community-wiki answers of a minimum length are eligible