0

I have created two fresh installations of Drupal, one version 8.9.17 and the other 9.2.3 and have been trying to get the Drupal console to work so that I can generate a module.

I used the following command in Composer and successfully downloaded it.

composer require drupal/console:~1.0 \
--prefer-dist \
--optimize-autoloader \
--sort-packages \
--no-update

Then run the following to avoid a Symphony conflict error.

composer update

This downloaded the relevant files and dependencies but when I try to access it from the command line (see below)

$ ../../../../vendor/bin/drupal

I get the following error.

Warning: require(drupal.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project_name\vendor\bin\drupal(21) : eval()'d code on line 3 PHP Fatal error: require(): Failed opening required 'drupal.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project_name\vendor\bin\drupal(21) : eval()'d code on line 3

Fatal error: require(): Failed opening required 'drupal.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project_name\vendor\bin\drupal(21) : eval()'d code on line 3

I looked on the Drupal console website and the advice was

This can be caused by the ioncube loader extension

As i'm working with Xammp on Windows 10, ioncube isn't available by default in the php.ini file. What should I be looking for to solve this?

EDIT It has been pointed out to me that Drush now includes generating commands and should be used instead of Drupal console which appears to be obsolete.

7
  • 2
    Last I heard (a while ago now) Drupal Console was obsolete and unmaintained - all of the generate commands are available with Drush though
    – Clive
    Aug 12, 2021 at 10:04
  • @Clive, Oh. I can't see that when I run Drush - pastebin.com/7BrZ4vXe but I have just looked on the Drush website and can see them listed there. Interesting, might need to do some more digging. Aug 12, 2021 at 10:17
  • Yeah I use it all the time: imgur.com/a/WiDdY3w
    – Clive
    Aug 12, 2021 at 10:21
  • 1
    @Clive one important and useful command missing in drush is entity type config export. Like node bundle config export. Which is present in Drupal console. Unless i am not aware of existing command. Aug 12, 2021 at 16:31
  • 1
    I don't think so @miststudent2011, I think that command is missing/not implemented like you say. Features provides similar functionality I think
    – Clive
    Aug 13, 2021 at 14:36

1 Answer 1

1

OK, so immediately after I posted the question I found the solution. I hope this helps anyone else in a similar situation.

The error is essentially saying that the drupal.php file cannot be found. So I went into the vendor/bin/drupal directory followed where the file was missing from:

vendor/drupal/console/bin/drupal

If you open that file, you will see the following code, which references the missing drupal.php file.

#!/usr/bin/env php
<?php
 
require 'drupal.php';

I compared this to Drush (which was working fine) and saw the Drush file was similar, but included the directory reference __DIR__. I updated the drupal.php file to the following and it now works as expected.

#!/usr/bin/env php
<?php
    
require __DIR__ . '/drupal.php';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.