Compare commits
No commits in common. "6aa311b35d855ae62f591ca0dbf9b4c982d34ba7" and "52ae66976a6d439577201db3e5e343d49aff4560" have entirely different histories.
6aa311b35d
...
52ae66976a
|
@ -7,7 +7,6 @@
|
|||
"require": {
|
||||
"xtreamwayz/pimple-container-interop": "^1.0",
|
||||
"zendframework/zend-expressive": "^1.0",
|
||||
"zendframework/zend-expressive-fastroute": "^1.2",
|
||||
"zendframework/zend-expressive-helpers": "^2.1"
|
||||
"zendframework/zend-expressive-fastroute": "^1.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php return [
|
||||
'middleware_pipeline' => [
|
||||
Zend\Expressive\Container\ApplicationFactory::ROUTING_MIDDLEWARE,
|
||||
Zend\Expressive\Container\ApplicationFactory::DISPATCH_MIDDLEWARE,
|
||||
],
|
||||
'routes' => [
|
||||
[
|
||||
'path' => '/',
|
||||
'middleware' => new Test\App\HomeAction,
|
||||
'allowed_methods' => [ 'GET' ],
|
||||
],
|
||||
],
|
||||
];
|
|
@ -1,21 +0,0 @@
|
|||
<?php return new ArrayObject([
|
||||
'middleware_pipeline' => [
|
||||
Zend\Expressive\Container\ApplicationFactory::ROUTING_MIDDLEWARE,
|
||||
['middleware' => Zend\Expressive\Helper\UrlHelperMiddleware::class],
|
||||
Zend\Expressive\Container\ApplicationFactory::DISPATCH_MIDDLEWARE,
|
||||
],
|
||||
'routes' => [
|
||||
[
|
||||
'path' => '/',
|
||||
'middleware' => Test\App\HomeAction::class,
|
||||
'allowed_methods' => [ 'GET' ],
|
||||
'name' => 'home',
|
||||
],
|
||||
[
|
||||
'path' => '/test/another/path',
|
||||
'middleware' => Test\App\HomeAction::class,
|
||||
'allowed_methods' => [ 'GET' ],
|
||||
'name' => 'other',
|
||||
],
|
||||
],
|
||||
]);
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Test\App\HomeAction;
|
||||
use Test\App\HomeFactory;
|
||||
use Xtreamwayz\Pimple\Container;
|
||||
use Zend\Expressive\Application;
|
||||
use Zend\Expressive\Container\ApplicationFactory;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
use Zend\Expressive\Helper\UrlHelperFactory;
|
||||
use Zend\Expressive\Helper\UrlHelperMiddleware;
|
||||
use Zend\Expressive\Helper\UrlHelperMiddlewareFactory;
|
||||
use Zend\Expressive\Router\FastRouteRouter;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
|
||||
$c = new Container;
|
||||
|
||||
$c['config'] = require 'config/config.php';
|
||||
|
||||
$c[RouterInterface::class] = function () { return new FastRouteRouter; };
|
||||
$c[UrlHelper::class] = new UrlHelperFactory;
|
||||
$c[UrlHelperMiddleware::class] = new UrlHelperMiddlewareFactory;
|
||||
$c[HomeAction::class] = new HomeFactory;
|
||||
$c[Application::class] = new ApplicationFactory;
|
||||
|
||||
return $c;
|
|
@ -1,12 +1,18 @@
|
|||
<?php
|
||||
|
||||
use Xtreamwayz\Pimple\Container;
|
||||
use Zend\Expressive\Application;
|
||||
use Zend\Expressive\Container\ApplicationFactory;
|
||||
|
||||
chdir(dirname(__DIR__));
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
$c = require 'config/container.php';
|
||||
$c = new Container;
|
||||
|
||||
$app = $c->get(Application::class);
|
||||
$c['config'] = new ArrayObject(require 'config/autoload/full.global.php');
|
||||
|
||||
$c[Application::class] = new ApplicationFactory;
|
||||
|
||||
$app = $c[Application::class];
|
||||
|
||||
$app->run();
|
||||
|
|
|
@ -4,20 +4,11 @@ namespace Test\App;
|
|||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
|
||||
class HomeAction
|
||||
{
|
||||
private $urlhelper;
|
||||
|
||||
public function __construct(UrlHelper $urlhelper)
|
||||
{
|
||||
$this->urlhelper = $urlhelper;
|
||||
}
|
||||
|
||||
public function __invoke(Request $req, Response $res, callable $next)
|
||||
{
|
||||
$result = sprintf("Hello World!<br/>\n%s", var_export($this->urlhelper->generate('other'), true));
|
||||
$res->getBody()->write($result);
|
||||
$res->getBody()->write("Hello World!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Test\App;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Expressive\Helper\UrlHelper;
|
||||
|
||||
class HomeFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $c)
|
||||
{
|
||||
try {
|
||||
$urlhelper = $c->get(UrlHelper::class);
|
||||
} catch (\Exception $e) {
|
||||
trigger_error("Ex: $e");
|
||||
}
|
||||
return new HomeAction($urlhelper);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue