In Zend Framework 2 it's very simple to add the initial module banner to the console applications.
All we need to is to implement the getConsoleBanner
and getConsoleUsage
methods and implement the Zend\ModuleManager\Feature\ConsoleUsageProviderInterface
or ConsoleBannerProviderInterface
interfaces.
This is good enough to dump those messages in the console when public/index.php
is started via CLI.
In Zend Framework 3 it's not the same.
Doing the same setup does not provide the same result. Actually in the console we see the default html page for the skeleton app the same way as we visit it via the browser.
That page is being seen before we install the custom module:
Here are the docs for the zend-mvc-console
module
https://zendframework.github.io/zend-mvc-console/intro/
Even after module is installed as suggested ('Zend\Mvc\Console'
added in module definitions) the console banners are not shown. I've tested with var dumping inside the methods and I'm able to view the data, so the framework executes those methods but shows no result in the console.
I've tested with console routes and controllers. Route is found, controller action is executed but nothing is shown in the cli again.
I've digged in the code of the framework and it seems the Zend\Mvc\Console\ResponseSender\ConsoleResponseSender
class is never executed.
Do I have to register some view_manager
strategies in order to get something displayed in the CLI?
Here are the sources on top of the zf3 skeleton application: https://gist.github.com/kachar/06f0c9096bcc1cc0b00f4612aed1b68b
Running the app:
$ php -v
PHP 7.0.6 (cli) (built: Apr 27 2016 14:00:40) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
$ php public/index.php
Application\Module::getConsoleBanner
Application\Module::getConsoleUsage
$ php public/index.php user
Application\Controller\IndexController::indexAction