Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When running this command from root it returns with a command not found.
drupal lightning:subprofile
Comments
Comment #2
AverilL CreditAttribution: AverilL as a volunteer commentedComment #3
balsamaHi. Do you actually have Lightning installed when you try to run that command? An unfortunate characteristic of DrupalConsole is that the providing extension actually needs to be enabled for DC to find it.
Comment #4
jmolivas CreditAttribution: jmolivas at weKnow Inc commented@balsama @AverilL Latest DrupalConsole allows you to load commands when Drupal is not installed I will check the command registration and try this new feature.
Comment #5
AverilL CreditAttribution: AverilL as a volunteer commented@Balsama Yes Lightning is installed.
Comment #6
AverilL CreditAttribution: AverilL as a volunteer commentedMore information which may be useful.
I have lightning installed in a drupalVM on nginx.
Comment #7
jmolivas CreditAttribution: jmolivas at weKnow Inc commented@balsama @AverilL I did some research last night. So far this is what I found:
Lightning is loading commands as services using lightning.services.yml this file is only loaded when the profile is installed.
DrupalConsole allows you to provide commands on modules & themes but the same issue is present.
I did some code changes on DrupalConsole to load commands from profile when drupal is not installed
https://patch-diff.githubusercontent.com/raw/hechoendrupal/drupal-consol...
As you can see I am loading `console.services.yml` instead of `lightning.services.yml` this is done to avoid breaking the site trying to load services from DrupalConsole classes if DrupalConsole is not downloaded on the site. I can send a PR to lightning adding this new file and moving service definition.
I still have two issues to fix
* DrupalConsole: Create and inject console.translator_manager Interface instead of concrete class.
* Lightning:
* Command is trying to load Drupal services like `info_parser` but not available. (we can try $this->infoParser = new \Drupal\Core\Extension\InfoParser(); and see if it works)
* Command is trying to load ComponentDiscovery class but class no loaded since profile is not installed autoloader is not loading profile/src files. (I can autoload all of the profile files same as I did with the Commands)
Comment #8
jmolivas CreditAttribution: jmolivas at weKnow Inc commentedI loaded the ComponentDiscovery.php manually and get the command to work and I was able to generate a profile when Drupal is not installed.
I still need to check why loading the src directory breaks the execution.
Comment #9
jmolivas CreditAttribution: jmolivas at weKnow Inc commentedI found the ofending class was `src/Task/SetXMLPropertyTask.php`
What I found about this class:
* Do not contains a namespace declaration.
* Contains a require_once 'phing/Task.php'; call.
Comment #10
btully CreditAttribution: btully commentedAny update or workaround for this?
Comment #11
phenaproxima@btully: If you can, try running the command from within docroot. Does that help?
Comment #12
firstlut CreditAttribution: firstlut commentedSwitching to docroot/ didn't help me.
However, I noticed that Lightning's composer.json file has a strict version constraint on Drupal Console (1.0.1). Wouldn't that keep all the fixes Jesus added upthread from taking effect?
Also, why would you limit DC like that? What's the reasoning, or was this unintentional?
Comment #13
phenaproximaFear not! We recently removed the constraint from Lightning, so it will be possible to use the latest version of Drupal Console as of the next release. It had been pinned to 1.0.1 due to old problems with our internal testing infrastructure, which have long since been resolved. :)
Comment #14
firstlut CreditAttribution: firstlut commentedWell, I jumped ahead and updated Drupal Console, and the command still doesn't show up, in either project or docroot. I'm attempting to use it before installation of the site.
Any other helpful hints?
Comment #15
phenaproximaAs @jmolivas suggests in #9, try removing SetXMLPropertyTask.php. Does that help? If so, we'll try to remove that in the next release. It is not used by Lightning or Drupal in any way; it's just an artifact from when we were using Phing to power our internal build scripts.
Comment #16
phenaproximaI tested this today. Unfortunately, it is not resolved.
I changed SetXMLPropertyTask.php to look like this:
With Drupal Console 1.8.0 installed, and Lightning not installed (but set up in a proper docroot with all dependencies), I ran:
vendor/bin/drupal lightning:subprofile
And I got this error:
[ERROR] Command "lightning:subprofile", is not a valid command name.
I'm at a bit of a loss for what to do here.
Comment #17
balsamaThis is now tested as part of our CI process.
Lightning needs to be installed and the command line needs to be able to talk to the database for this command to work. To verify, run the following command:
$ drupal site:status
You should see the following in the output:
and
Database connection
with your database connection details listed.If you are using a virtual machine, you will need to run the Drupal Console commands from within the VM.