Answer the question
In order to leave comments, you need to log in
How to create a console command in Yii2 advanced?
The situation is this: I have 2 machines, each with the same environment and project source files. On one it works, on the other it doesn't. And I can't figure out why...
File var/www/site/console/config/main.php
return [
...
'controllerNamespace' => 'console\controllers',
<?
namespace console\controllers;
use Yii;
class TestController extends \yii\console\Controller
{
public function actionIndex()
{
print 1;
}
}
php yii test/index
<?
namespace console\controllers;
use Yii;
class TestController extends \yii\console\Controller
{
public function actionIndex()
{
print 1;
}
}Exception 'yii\base\UnknownClassException' with message 'Unable to find 'console\controllers\TestController' in file: /var/www/site/console/controllers/TestController.php. Namespace missing?'
in /var/www/site/vendor/yiisoft/yii2/BaseYii.php:291
Stack trace:
#0 [internal function]: yii\BaseYii::autoload('console\\control...')
#1 [internal function]: spl_autoload_call('console\\control...')
#2 /var/www/site/vendor/yiisoft/yii2/base/Module.php(633): class_exists('console\\control...')
#3 /var/www/site/vendor/yiisoft/yii2/base/Module.php(591): yii\base\Module->createControllerByID('test')
#4 /var/www/site/vendor/yiisoft/yii2/base/Module.php(517): yii\base\Module->createController('index')
#5 /var/www/site/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('test/index', Array)
#6 /var/www/site/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('test/index', Array)
#7 /var/www/site/vendor/yiisoft/yii2/base/Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request))
#8 /var/www/site/yii(27): yii\base\Application->run()
Answer the question
In order to leave comments, you need to log in
Php short tags - he also showed you the contents of the file
Hexagon hackneyed design. You won't surprise anyone anymore. Start learning SVG. There, the creation of polygonal shapes is 2 + 2. Here's a little course on the basics of SVG
If you're good at overclocking and learning JS, you can create sites like these:
Waaark
Cédric Pereira
Humaan
LOCUS SOLUS
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question