git checkout 2.1
$ build/build
This is Yii version 2.1.0-dev.
The following commands are available:
- help Provides help information about console commands.
help/index (default) Displays available commands or the detailed information
help/list List all available controllers and actions in machine readable format.
help/list-action-options List all available options for the $action in machine readable format.
help/usage Displays usage information for $action.
To see the help of each command, enter:
build help <command-name>
It should list all other commands from build/controllers directory.
see above.
config code looks correct to me, so it seems something is broken:
https://github.com/yiisoft/yii2/blob/9ba943c4ad40436e79e3c955e5bc19a5ff919f34/build/build#L32-L39
| Q | A
| ---------------- | ---
| Yii version | 2.1-dev
| PHP version |
| Operating system |
Function class_exists() returns false for controllers classes here:
It seems like class autoloading doesn't work.
That's probably because Yii's autoloading has been removed, so settings alias (Yii::setAlias('@yii/build', __DIR__);) no longer affects autoloading. yii\build namespace should be added to composer.json autoloading rules.
I see, so whenever I want to introduce a new namespace in a project one needs to run a composer command? Not sure I like this...
I see, so whenever I want to introduce a new namespace in a project one needs to run a composer command? Not sure I like this...
No, you can also dynamically add namespaces.
For example this issue can be fixed with:
foreach ($composerAutoload as $autoload) {
if (file_exists($autoload)) {
$autoloader = require $autoload;
$autoloader->setPsr4("yii\\build\\", __DIR__);
$vendorPath = dirname($autoload);
break;
}
}
Pay attention to these lines:
...
$autoloader = require $autoload;
$autoloader->setPsr4("yii\\build\\", __DIR__);
...
In this case, you do not need to edit composer.json.
But I think that adding lines to composer.json is a cleaner and more explicit way to declare a new namespace in the case of build app.
Most helpful comment
That's probably because Yii's autoloading has been removed, so settings alias (
Yii::setAlias('@yii/build', __DIR__);) no longer affects autoloading.yii\buildnamespace should be added tocomposer.jsonautoloading rules.