Created
June 19, 2016 03:03
-
-
Save sasezaki/ff18e4384879b671c8b906312e0fb207 to your computer and use it in GitHub Desktop.
example , run zend-mvc minimal for debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// INSTALL: $composer require zendframework/zend-mvc:^3 | |
// USAGE: $php -d allow_url_include=1 zend-mvc-mini.php | |
namespace Application { | |
use Zend\Router\Http\Literal; | |
use Zend\Router\Http\Segment; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use Zend\ServiceManager\Factory\InvokableFactory; | |
require_once __DIR__.'/vendor/autoload.php'; | |
class Module | |
{ | |
public function getConfig() | |
{ | |
return [ | |
'router' => [ | |
'routes' => [ | |
'home' => [ | |
'type' => Literal::class, | |
'options' => [ | |
'route' => '/', | |
'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' => 'data://,<html><body><?= $this->content ?></body></html>', | |
'application/index/index' => 'data://,<?= $this->escapeHtml($this->foo) ?>', | |
'error/404' => 'data://,404', | |
'error/index' => 'data://,<?php var_dump($this->exception);?>', | |
], | |
], | |
]; | |
} | |
} | |
} | |
namespace Application\Controller { | |
use Zend\Mvc\Controller\AbstractActionController; | |
class IndexController extends AbstractActionController | |
{ | |
public function indexAction() | |
{ | |
return ['foo' => '<bar>']; | |
} | |
} | |
} | |
namespace { | |
Zend\Mvc\Application::init([ | |
'modules' => ['Zend\Router', 'Application'], | |
'module_listener_options' => [ | |
'module_paths' => ['.'] | |
] | |
])->run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment