-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace problems with Site-Wide Drush Commands #4641
Comments
Proposed fix is to alter drush composer.json as per the workaround. I can create a PR if you would accept this change. |
I have been using site-wide Drush commands for a while, and definitely something wrong with the Command file detection. But my workaround is the following:
File content ./drush/drush.yml drush:
paths:
config:
- '${drush.vendor-dir}/../drush/Commands/contrib/foo/Commands'
- '${drush.vendor-dir}/../drush/drush.app.yml'
- '${drush.vendor-dir}/../drush/drush.local.yml'
include:
- '${drush.vendor-dir}/../drush/Commands/contrib/foo' File content ./drush/drush.app.yml options:
root: '${drush.vendor-dir}/../docroot' File content ./drush/Commands/contrib/foo/composer.json {
"name": "drupal/foo",
"type": "drupal-drush",
"autoload": {
"psr-4": {
"Drush\\Commands\\foo\\": "Commands/foo/",
"Drush\\Generators\\foo\\": "Generators/foo/",
"Drupal\\foo\\": "src/"
}
}
} File content ./drush/Commands/contrib/foo/Commands/foo/FooBarCommands.php <?php
namespace Drush\Commands\foo;
class FooBarCommands {}
|
Commands and Generator detection related issues:
|
See the Example Drush Extension. This example does not add an entry to I don't think we should put an entry in Drush to autoload extension class files though. |
It's fine by me to resolve this with documentation. The two actions below would have resolved my uncertainty meaning I didn't raise an issue here.
|
Pretty big improvement merged in #4696. |
Describe the bug
Docs for Site-Wide Drush Commands state to use a namespace
Drush\Commands
. However this namespace isn't registered as an auto-loader, so it' doesn't work to try and use files in this directory.To Reproduce
Create a site-wide command in
$PROJECT_ROOT/drush/Commands/ExampleCommands.php
that extends from a base class in the same directory.Expected behavior
It works.
Actual behavior
The base class cannot be found.
Workaround
Add a line to your own composer.json.
System Configuration
The text was updated successfully, but these errors were encountered: