Move existing code exactly to config file
The directory structure is taken from zendframework/zend-expressive-skeleton.
This commit is contained in:
parent
0f2f3ac00b
commit
4ba3a3ffdb
2 changed files with 15 additions and 6 deletions
13
config/autoload/full.global.php
Normal file
13
config/autoload/full.global.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php return [
|
||||
'middleware_pipeline' => [
|
||||
Zend\Expressive\Container\ApplicationFactory::ROUTING_MIDDLEWARE,
|
||||
Zend\Expressive\Container\ApplicationFactory::DISPATCH_MIDDLEWARE,
|
||||
],
|
||||
'routes' => [
|
||||
[
|
||||
'path' => '/',
|
||||
'middleware' => function ($req, $res, $next) { $res->getBody()->write("Hello World!"); },
|
||||
'allowed_methods' => [ 'GET' ],
|
||||
],
|
||||
],
|
||||
];
|
|
@ -9,14 +9,10 @@ require_once 'vendor/autoload.php';
|
|||
|
||||
$c = new Container;
|
||||
|
||||
$c['config'] = new ArrayObject(require 'config/autoload/full.global.php');
|
||||
|
||||
$c[Application::class] = new ApplicationFactory;
|
||||
|
||||
$app = $c[Application::class];
|
||||
|
||||
$app->get('/', function ($req, $res, $next) {
|
||||
$res->getBody()->write("Hello World!");
|
||||
});
|
||||
|
||||
$app->pipeRoutingMiddleware();
|
||||
$app->pipeDispatchMiddleware();
|
||||
$app->run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue