Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Created June 19, 2016 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasezaki/ff18e4384879b671c8b906312e0fb207 to your computer and use it in GitHub Desktop.
Save sasezaki/ff18e4384879b671c8b906312e0fb207 to your computer and use it in GitHub Desktop.
example , run zend-mvc minimal for debug
<?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