0
我使用了Zend Framework版本2.我遵循here的說明,但是我的項目運行不正常。 這裏是我的代碼:ZF2控制檯路由運行不正常
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
}
}
,當我試圖使用命令PROMT運行它
C:\webserver\www\program\phpcas\zf2-console>php public/index.php show users
始終顯示來自Module.php getConsoleUsage()
,誰能幫助我,如何解決它?
THX對您有所幫助。它正在工作.. –