I have application created in Zend Framework 2. I would like to run controller action as cron job. I read a lot about it but I don't know how to run it.
I did something like that. I added console route to module's module.config.php
'console' => array(
'router' => array(
'routes' => array(
'cronroute' => array(
'options' => array(
'route' => 'updateproducts',
'defaults' => array(
'controller' => 'Application\Controller\Console',
'action' => 'update'
)
)
)
),
),
),
I created Controller named ConsoleController
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Application\Model;
use Application\Model\Auth;
class ConsoleController extends AbstractActionController
{
protected $usersTable = null;
public function updateAction()
{
$this->getUsersTable()->cronTest();
return false;
}
public function getUsersTable()
{
if (!$this->usersTable) {
$sm = $this->getServiceLocator();
$this->usersTable = $sm->get('Application\Model\UsersTable');
}
return $this->usersTable;
}
Inside Auth.php
public function cronTest(){
$data = array(
'login' => 'cronZend'
);
$this->tableGateway->insert($data);
}
I think that everything here is OK and I tried to write something inside command line on shared server:
/usr/local/bin/php /home/****/domains/****/public_html/public/index.php updateproducts
and it doesn't work. When I test it writing something like that in cron.php
$dbc = mysqli_connect(****);
$query = "INSERT INTO vm_user (login) VALUES ('cron')";
mysqli_query($dbc, $query);
and in command line
/usr/local/bin/php /home/****/domains/****/public_html/cron.php
it works fine. Could anyone tell me what is wrong or how to do it?
Related
I used Zend Framework version 2. I follow the instruction from here but my project doesn't run well.
Here's my code :
module.config.php
return array(
'controllers'=> array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
),
),
'router' => array(
'routes' => array(
)
),
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
'list-users' => array(
'options' => array(
'route' => 'show [all|disabled|deleted]:mode users [--verbose|-v]',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'showusers'
)
)
),
),
),
),
);
Module.php
public function getConsoleUsage(Console $console)
{
return array(
'Finding and listing users',
'list [all|disabled] users [-w]' => 'Show a list of users',
'find user [--email=] [--name=]' => 'Attempt to find a user by email or name',
array('[all|disabled]', 'Display all users or only disabled accounts'),
array('--email=EMAIL', 'Email of the user to find'),
array('--name=NAME', 'Full name of the user to find.'),
array('-w', 'Wide output - When listing users use the whole available screen width' ),
'Manipulation of user database:',
'delete user <userEmail> [--verbose|-v] [--quick]' => 'Delete user with email <userEmail>',
'disable user <userEmail> [--verbose|-v]' => 'Disable user with email <userEmail>',
array( '<userEmail>' , 'user email' , 'Full email address of the user to change.' ),
array( '--verbose' , 'verbose mode' , 'Display additional information during processing' ),
array( '--quick' , '"quick" operation' , 'Do not check integrity, just make changes and finish' ),
array( '-v' , 'Same as --verbose' , 'Display additional information during processing' ),
);
}
IndexController.php
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel();
}
public function showusersAction(){
$request = $this->getRequest();
return "HOLLLLLLLLLLLLAAAAAAAAAAAA"; // show it in the console
}
}
When i tried to run it using command promt :
C:\webserver\www\program\phpcas\zf2-console>php public/index.php show users
Always showing getConsoleUsage() from Module.php, can anyone help me, how to fix it ?
From my (little) experience, it seems that your module.config.php and your Module.php files are correct.
Usually, when I use the console, my controllers are slightly different :
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
// For Cron/Console
use Zend\Console\Request as ConsoleRequest;
use Zend\Console\ColorInterface as Color;
class IndexController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel();
}
public function showusersAction()
{
// Initialize variables.
$request = $this->getRequest();
$console = $this->getServiceLocator()->get('console');
// Make sure that we are running in a console and the user has not tricked our
// application into running this action from a public web server.
if (!$request instanceof ConsoleRequest) {
throw new \RuntimeException('You can only use this action from a console!');
}
// Retrieve values from value flags using their name.
$verbose = (bool)$request->getParam('verbose', false) || (bool)$request->getParam('v', false); // default false
/* ...your other flags... */
/* ...do what you want to do... */
// Let's confirm it works
$console->writeline("Groovy Baby!");
I'm building my first Zend Framework 2 application with the skeleton tutorial. But whenever I try to call any plugin from any controller, I get the error message:
A plugin by the name "PLUGIN_NAME" was not found in the plugin manager
Zend\Mvc\Controller\PluginManager
Unfortunately I don't know which part of the code could help you to help me. I post some files which I think could be important.
config/modules.config
return [
'Zend\Router',
'Zend\Validator',
'Zend\Form',
'Album',
'Application',
'User',
];
module/User/src/Module.php
<?php
namespace User;
use User\Model\User;
use User\Model\UserTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
class Module
{
const VERSION = '1.0.0dev';
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'User\Model\UserTable' => function($sm) {
$tableGateway = $sm->get('UserTableGateway');
$table = new UserTable($tableGateway);
return $table;
},
'UserTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new User());
return new TableGateway('user', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
}
module/User/config/module.config.php
<?php
namespace User;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\Router\Http\Segment;
return [
'controllers' => [
'factories' => [
Controller\UserController::class => InvokableFactory::class,
],
'invokables' => [
'User\Controller\User' => 'User\Controller\UserController',
],
],
'router' => [
'routes' => [
'user' => [
'type' => Segment::class,
'options' => [
'route' => '/user[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\UserController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'user' => __DIR__ . '/../view',
],
],
];
I'm trying to call my plugins like this from a controller action:
$this->flashMessanger()->...
$this->identity();
$this->getServiceLocator();
Because I really needed the Service Locator, I found a workaround, which is not so nice I think, but works for me:
$sm = $this->getEvent()->getApplication()->getServiceManager();
But I guess something is wrong here.
Edit:
For a better reproduction of what I did (I installed Zend Framework again and it still gives me the same error):
Installed Zend Framework (2.4 I guess?) by this installation guide (https://framework.zend.com/manual/2.4/en/ref/installation.html). I installed it with the following command:
composer create-project -sdev --repository-url="https://packages.zendframework.com" zendframework/skeleton-application
On the installation, when I was asked if I want to install a minimum install, I chose "No". Every next question I answered with "Yes" (the installer asks to install a lot of modules, I installed them all).
The installer asked in which config I want to inject "ZendDeveloperTools". I answered 2 (config/development.config.php.dist). For all others I chose 1 (config/modules.config.php).
I tested the skeleton application by calling the url in my browser, it worked.
I downloaded the Album module from GitHub here (https://github.com/Hounddog/Album).
I copied the album module to my modules folder.
I added the entry 'Album' to my config/modules.config.php file
I browsed to the album page
I'm getting the error:
A plugin by the name "getServiceLocator" was not found in the plugin
manager Zend\Mvc\Controller\PluginManager
I assume the reason for this error is the getAlbumTable() method in the AlbumController
public function getAlbumTable()
{
if (!$this->albumTable) {
$sm = $this->getServiceLocator();
$this->albumTable = $sm->get('Album\Model\AlbumTable');
}
return $this->albumTable;
}
In the ZF2 docs for controller plugins you can read that your controller has to implement the following methods: setPluginManager, getPluginManager and plugin. You can also read:
For an extra layer of convenience, both AbstractActionController and AbstractActionController have __call() implementations that allow you to retrieve plugins via method calls:
$plugin = $this->url();
Does your controller extend AbstractActionController or AbstractActionController? If yes, it should work as mentioned in the docs (so those methods you mention in your question should work).
Since you didn't share any controller code it is hard to say whether this is the problem...
UPDATE
The error you get is not related to the configuration of your ControllerPluginManager, but you get this error because you are doing:
$sm = $this->getServiceLocator();
Since the method getServiceLocator doesn't exist the magic __call() method is executed and this leads to the error.
This is because in the latest versions of ZF2 the controller classes are no longer 'service locator aware' meaning you cannot retrieve the ServiceManager by calling $this->getServiceLocator().
Instead you will have to inject your Album\Model\AlbumTable service into the controller class inside a factory:
1) Add a constructor method to your controller class:
public function __construct(AlbumTable $albumTable){
$this->albumTable = $albumTable;
}
2) Create a factory for your controller:
<?php
namespace Album\Controller\Factory;
use Album\Controller\AlbumController;
class AlbumControllerFactory implements FactoryInterface
{
/**
* #param ServiceLocatorInterface $serviceLocator
* #return AlbumController
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$controllerPluginManager = $serviceLocator;
$serviceManager = $controllerPluginManager->get('ServiceManager');
$albumTable = $serviceManager->get('Album\Model\AlbumTable');
return new AlbumController($albumTable);
}
}
3) Register your controller factory inside your module.config.php:
'factories' => [
`Album\Controller\AlbumController` => `Album\Controller\Factory\AlbumControllerFactory`,
],
The function getAlbumTable() was used in ZF2 tutorial but in ZF3 it was replaced by member table.
Change the deleteAction() function in AlbumController.php to read:
public function deleteAction()
{
$id = (int) $this->params()->fromRoute('id', 0);
if (!$id) {
return $this->redirect()->toRoute('album');
}
$request = $this->getRequest();
if ($request->isPost()) {
$del = $request->getPost('del', 'No');
if ($del == 'Yes') {
$id = (int) $request->getPost('id');
$this->table->deleteAlbum($id);
}
// Redirect to list of albums
return $this->redirect()->toRoute('album');
}
return array(
'id' => $id,
'album' => $this->table->getAlbum($id)
);
}
Note the two lines reading $this->table->... instead of $this->getAlbumTable()->...
I am trying to learn ZF2 and I just want to specify Javascript and CSS files to be included in my layout. I currently pass an array of paths relative to my public directory to my view and then loop through them. I would like to make use of the built in ZF2 solution using:
$this->headScript();
$this->headStyle();
I have tried many suggested methods on similar questions, but I must not be following them correctly.
One of the solutions I tried which seemed to make sense was here by using either of these in my controller:
$this->getServiceLocator()->get('Zend\View\HelperPluginManager')->get('headLink')->appendStylesheet('/css/style.css');
$this->getServiceLocator()->get('viewhelpermanager')->get('headLink')->appendStylesheet('/css/style.css');
I am not sure what viewhelpermanager it seems like a placeholder the poster used, but I have seen it in more than one question. I went ahead and found the location of Zend\View\HelperPluginManager but that did not work either.
By "not working" I mean my page is displayed without CSS and there is zero output from these:
$this->headScript();
$this->headStyle();
It seems like such a simple task and I do not know why I am having this much of a difficulty.
EDIT #1:
Here is my controller:
<?php
namespace CSAdmin\Controller;
use Zend\View\Model\ViewModel;
use Zend\View\HelperPluginManager;
class LoginController extends AdminController
{
public function __construct() {
parent::__construct();
}
public function indexAction()
{
//Set Action specific Styles and Scripts
$viewHelperManager = $this->getServiceLocator()->get(`ViewHelperManager`);
$headLinkHelper = $viewHelperManager->get('HeadLink');
$headLinkHelper->appendStylesheet('/css/admin/form.css','text/css',array());
$headLinkHelper->appendStylesheet('/css/admin/styles.css','text/css',array());
//Override view to use predefined Admin Views
$view = new ViewModel(array('data'=>$this->data));
$view->setTemplate('CSAdmin/login/login.phtml'); // path to phtml file under view folder
//Set the Admin Layout
$layout = $this->layout();
$layout->setVariable('layout', $this->layoutVars);
$layout->setTemplate('layout/CSAdmin/login.phtml');
//Render Page
return $view;
}
My AdminController:
<?php
namespace CSAdmin\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class AdminController extends AbstractActionController
{
protected $data = array();
protected $layoutVars = array();
protected $viewHelper;
public function __construct() {
$this->layoutVars['customStyles'] = array();
$this->layoutVars['customScripts'] = array();
$this->layoutVars['miscCode'] = array();
//$this->viewHelper = $viewHelper;
}
}
EDIT #2:
#Wilt Error message for the above to controllers:
Line 19 is
$viewHelperManager = $this->getServiceLocator()->get("ViewHelperManager");
EDIT #3:
There are two modules involved here. Admin and CSAdmin, the controllers from Admin extend the controllers from CSAdmin and all of the controllers from CSAdmin extend a base controller within CSAdmin AdminController. AdminController extends AbstractActionController.
My controller and service_manager arrays for each module.config.php for both modules are below:
Admin:
'service_manager' => array(
'invokables' => array(
'CSAdmin\Form\LoginForm' => 'CSAdmin\Form\LoginForm'
),
'factories' => array(
)
),
'controllers' => array(
'invokables' => array(
),
'factories' => array(
'Admin\Controller\Login' => 'Admin\Factory\LoginControllerFactory',
)
),
// This lines opens the configuration for the RouteManager
'router' => array(
// Open configuration for all possible routes
'routes' => array(
'admin' => array(
'type' => 'literal',
'options' => array(
'route' => '/admin',
'defaults' => array(
'controller' => 'Admin\Controller\Login',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'home' => array(
'type' => 'literal',
'options' => array(
'route' => '/home',
'defaults' => array(
'controller' => 'Admin\Controller\Login',
'action' => 'home'
)
)
),
)
)
)
)
CSAdmin:
'service_manager' => array(
'invokables' => array(
),
'factories' => array(
'CSAdmin\Mapper\LoginMapperInterface' => 'CSAdmin\Factory\LoginMapperFactory',
'CSAdmin\Service\LoginServiceInterface' => 'CSAdmin\Factory\LoginServiceFactory'
)
),
'controllers' => array(
'invokables' => array(
),
'factories' => array(
'CSAdmin\Controller\Admin' => 'CSAdmin\Factory\AdminControllerFactory',
'CSAdmin\Controller\Login' => 'CSAdmin\Factory\LoginControllerFactory',
)
)
EDIT #4:
/module/Admin/src/Admin/Factory/LoginControllerFactory.php:
namespace Admin\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Admin\Controller\LoginController;
use CSAdmin\Service\LoginServiceInterface;
class LoginControllerFactory implements FactoryInterface
{
/**
* Create service
*
* #param ServiceLocatorInterface $serviceLocator
* #return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$realServiceLocator = $serviceLocator->getServiceLocator();
$loginService = $realServiceLocator->get('CSAdmin\Service\LoginServiceInterface');
$loginForm = $realServiceLocator->get('FormElementManager')->get('CSAdmin\Form\LoginForm');
return new LoginController(
$loginService,
$loginForm
);
}
}
/module/CSAdmin/src/CSAdmin/Factory/AdminControllerFactory.php:
namespace CSAdmin\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use CSAdmin\Controller\AdminController;
use Zend\View\Helper\BasePath;
class AdminControllerFactory implements FactoryInterface
{
/**
* Create service
*
* #param ServiceLocatorInterface $serviceLocator
* #return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$realServiceLocator = $serviceLocator->getServiceLocator();
//$viewHelper = $realServiceLocator->get('Zend\View\Helper\BasePath');
//return new AdminController($viewHelper);
return new AdminController();
}
}
/module/CSAdmin/src/CSAdmin/Factory/LoginControllerFactory.php:
namespace CSAdmin\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use CSAdmin\Controller\LoginController;
class LoginControllerFactory implements FactoryInterface
{
/**
* Create service
*
* #param ServiceLocatorInterface $serviceLocator
* #return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$realServiceLocator = $serviceLocator->getServiceLocator();
$loginService = $realServiceLocator->get('CSAdmin\Service\LoginServiceInterface');
$loginForm = $realServiceLocator->get('FormElementManager')->get('CSAdmin\Form\LoginForm');
return new LoginController(
$loginService,
$loginForm
);
}
}
EDIT #5:
After correcting the type of quotes being used I am still not getting the stylesheets in my layout. As a test I change ->appendStylesheet() to ->someMethod() and it properly reports that the method does not exist. So it definitely has an instance of the HeadLink object. As a next step I decided to just try defining everything in the layout file and it still does not use the stylesheets. See below for the exact code used in the <head> tag of my layout file.
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $this->layout['title']; ?></title> //Intend to change eventually.
<?php
$this->headLink()->appendStylesheet('/css/admin/form.css');
$this->headLink()->appendStylesheet('/css/admin/styles.css');
echo $this->headScript();
echo $this->headStyle(); //This outputs nothing when viewing with the chrome debugger.
</head>
EDIT #6:
In order to get it to work, instead of using:
echo $this->headScript();
echo $this->headStyle();
I just had to do:
echo $this->headLink();
You will have to add echo to output the result...
echo $this->headScript();
echo $this->headStyle();
echo $this->headLink();
UPDATE
To get the Zend\View\HelperPluginManager in your controller you can do like this:
$viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
Then you can do:
$headLinkHelper = $viewHelperManager->get('headLink');
UPDATE 2
Another thing, but it is a bit ridiculous, no wonder it was hard to find.
You used wrong quotes:
`ViewHelperManager` //You cannot use these: `
Try like this:
'ViewHelperManager'
or like this:
"ViewHelperManager"
you need to append file in this way
$this->headScript()->appendFile(
'/js/prototype.js',
'text/javascript',
array('conditional' => 'lt IE 7')
);
then you write it
echo $this->headScript();
note echo head script is required only one time. otherwise you inser js more time
more info at
http://framework.zend.com/manual/current/en/modules/zend.view.helpers.head-script.html
I have 2 factories.
The first is a Controller Factory:
<?php
namespace Blog\Factory;
use Blog\Controller\ListController;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class ListControllerFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$realServiceLocator = $serviceLocator->getServiceLocator();
$postService = $realServiceLocator->get('Blog\Service\PostServiceInterface');
return new ListController($postService);
}
}
The second is a Post ServiceFactory:
<?php
namespace Blog\Factory;
use Blog\Service\PostService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class PostServiceFactory implements FactoryInterface
{
/**
* Create service
*
* #param ServiceLocatorInterface $serviceLocator
* #return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return new PostService(
$serviceLocator->get('Blog\Mapper\PostMapperInterface')
);
}
}
Here is my module config:
<?php
return array(
'service_manager' => array(
'factories' => array(
'Blog\Service\PostServiceInterface' => 'Blog\Factory\PostServiceFactory'
)
),
'controllers' => array(
'factories' => array(
'Blog\Controller\List' => 'Blog\Factory\ListControllerFactory'
)
),
'router' => array(
// Open configuration for all possible routes
'routes' => array(
// Define a new route called "post"
'post' => array(
// Define the routes type to be "Zend\Mvc\Router\Http\Literal", which is basically just a string
'type' => 'literal',
// Configure the route itself
'options' => array(
// Listen to "/blog" as uri
'route' => '/blog',
// Define default controller and action to be called when this route is matched
'defaults' => array(
'controller' => 'Blog\Controller\List',
'action' => 'index',
)
)
)
)
),
'view_manager' => array(
'template_path_stack' => array(
__DIR__ . '/../view',
),
)
);
In the controller factory, I have to call getServiceLocator against the ServiceLocatorInterface, followed by the get call. however in the post service factory i just call get. I did a dump and it looks like both are the Zend\ServiceManager\ServiceManager classes. When I tried performing the getServiceLocator call against the post service factory service locator it errored no method found.
Im not quite understanding whats going on?
Controller factories are called in a different way than casual service factories. The ServiceLocator passed to createService is actually not the ServiceManager you are looking for but an instance of ControllerManager.
If you try this:
public function createService(ServiceLocatorInterface $serviceLocator)
{
$realServiceLocator = $serviceLocator->getServiceLocator();
$postService = $realServiceLocator->get('Blog\Service\PostServiceInterface');
var_dump(get_class($serviceLocator));
return new ListController(postService );
}
you'll get the output:
string(37) "Zend\Mvc\Controller\ControllerManager"
while the same dump in your PostServiceFactory will give you:
string(34) "Zend\ServiceManager\ServiceManager"
From the Zend 2 documentation:
http://framework.zend.com/manual/current/en/in-depth-guide/services-and-servicemanager.html#writing-a-factory-class
When using a Factory-Class that will be called from the ControllerManager it will actually inject itself as the $serviceLocator. However, we need the real ServiceManager to get to our Service-Classes. This is why we call the function getServiceLocator() who will give us the real ServiceManager.
I have set up a couple of console routes in a Zend Framework 2 project to test out, and while it works on linux (ubuntu 12.10) , it won't work on my windows 7 machine using command prompt or cygwin. I just get the following error message:
Reason for failure: Invalid arguments or no arguments provided
In my module.config.php file, I have
'console' => array(
'router' => array(
'routes' => array(
'some-route' => array(
'options' => array(
'route' => 'some route',
'defaults' => array(
'controller' => 'Application\Controller\Cron',
'action' => 'some-route'
)
)
),
'another-route' => array(
'options' => array(
'route' => 'another route',
'defaults' => array(
'controller' => 'Application\Controller\Cron',
'action' => 'another-route'
)
)
)
)
)
)
And in my controller
class CronController extends AbstractActionController
{
public function someRouteAction()
{
return 'some route called' . PHP_EOL;
}
public function anotherRouteAction()
{
return 'some other route called' . PHP_EOL;
}
}
Does anyone know of a reason why the exact same code works on ubuntu but not on windows?
1- You can check the router factory on Zend/Mvc/Service/RouterFactory.php
to make sure that your console routing configuration is not in cache.
public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
{
$config = $serviceLocator->get('Configuration') ;
//#ToDo Remove
print_r($config);
if(
$rName === 'ConsoleRouter' ||
($cName === 'router' && Console::isConsole())
) {
if(isset($config['console']) && isset($config['console']['router'])){
$routerConfig = $config['console']['router'] ;
} else {
$routerConfig = array();
}
$router = ConsoleRouter::factory($routerConfig) ;
} else {
[…]
}
return $router ;
}
Alternatively it is necessary to verify in application.config.php if config_cache_enabled is true