Skip to content

Instantly share code, notes, and snippets.

@kachar
Created July 28, 2016 12:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kachar/06f0c9096bcc1cc0b00f4612aed1b68b to your computer and use it in GitHub Desktop.
Save kachar/06f0c9096bcc1cc0b00f4612aed1b68b to your computer and use it in GitHub Desktop.
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Zend\Mvc\Console\Controller\AbstractConsoleController;
use Zend\Mvc\Console\View\ViewModel;
class IndexController extends AbstractConsoleController
{
public function indexAction()
{
$this->getConsole()->writeText(__METHOD__); // Only this line is being shown in the console.
$model = new ViewModel();
$model->setResult(__CLASS__);
return $model;
}
}
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application;
use Zend\Mvc\Console\Router\Simple;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'router' => [
'routes' => [
'home' => [
'type' => Literal::class,
'options' => [
'route' => '/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
'application' => [
'type' => Segment::class,
'options' => [
'route' => '/application[/:action]',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
],
],
'console' => [
'router' => [
'routes' => [
'user' => [
'type' => Simple::class,
'options' => [
'route' => 'user',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
],
],
],
'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
],
],
'view_manager' => [
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
],
'template_path_stack' => [
__DIR__ . '/../view',
],
],
];
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application;
use Zend\Console\Adapter\AdapterInterface as Console;
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
use Zend\ModuleManager\Feature\ConsoleBannerProviderInterface;
class Module implements ConsoleUsageProviderInterface, ConsoleBannerProviderInterface
{
const VERSION = '3.0.0dev';
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function getConsoleBanner(Console $console)
{
echo __METHOD__ . PHP_EOL;
return 'Skeleton application ' . self::VERSION;
}
public function getConsoleUsage(Console $console)
{
echo __METHOD__ . PHP_EOL;
return [
// Describe available commands
'user' => 'Run some action',
];
}
}
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* List of enabled modules for this application.
*
* This should be an array of module namespaces used in the application.
*/
return [
'Zend\Mvc\Console',
'Zend\Router',
'Zend\Validator',
'Application',
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment