diff --git a/composer.json b/composer.json index da746f03..ec6e6ce9 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,29 @@ { "name": "shlinkio/shlink", "type": "project", - "homepage": "http://shlink.io", + "homepage": "https://shlink.io", "description": "A self-hosted and PHP-based URL shortener application with CLI and REST interfaces", "license": "MIT", "authors": [ { "name": "Alejandro Celaya Alastrué", - "homepage": "http://www.alejandrocelaya.com", + "homepage": "https://www.alejandrocelaya.com", "email": "alejandro@alejandrocelaya.com" } ], "require": { "php": "^5.6 || ^7.0", - "zendframework/zend-expressive": "^1.0", - "zendframework/zend-expressive-fastroute": "^1.3", - "zendframework/zend-expressive-twigrenderer": "^1.0", - "zendframework/zend-stdlib": "^2.7", + "zendframework/zend-expressive": "^2.0", + "zendframework/zend-expressive-fastroute": "^2.0", + "zendframework/zend-expressive-twigrenderer": "^1.4", + "zendframework/zend-stdlib": "^3.0", "zendframework/zend-servicemanager": "^3.0", "zendframework/zend-paginator": "^2.6", - "zendframework/zend-config": "^2.6", + "zendframework/zend-config": "^3.0", "zendframework/zend-i18n": "^2.7", "zendframework/zend-config-aggregator": "^0.1", - "acelaya/zsm-annotated-services": "^0.2.0", - "acelaya/ze-content-based-error-handler": "^1.0", + "acelaya/zsm-annotated-services": "^1.0", + "acelaya/ze-content-based-error-handler": "^2.0", "doctrine/orm": "^2.5", "guzzlehttp/guzzle": "^6.2", "symfony/console": "^3.0", diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index d014f9ab..e2b88ba8 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -4,6 +4,7 @@ use Zend\Expressive\Container; use Zend\Expressive\Router; use Zend\Expressive\Template; use Zend\Expressive\Twig; +use Zend\Stratigility\Middleware\ErrorHandler; return [ @@ -13,6 +14,7 @@ return [ Template\TemplateRendererInterface::class => Twig\TwigRendererFactory::class, \Twig_Environment::class => Twig\TwigEnvironmentFactory::class, Router\RouterInterface::class => Router\FastRouteRouterFactory::class, + ErrorHandler::class => Container\ErrorHandlerFactory::class, ], ], diff --git a/config/autoload/errorhandler.local.php.dist b/config/autoload/errorhandler.local.php.dist index 40316fd9..552b6ffb 100644 --- a/config/autoload/errorhandler.local.php.dist +++ b/config/autoload/errorhandler.local.php.dist @@ -1,6 +1,5 @@ [ @@ -21,7 +20,7 @@ return [ 'error_handler' => [ 'plugins' => [ 'factories' => [ - ContentBasedErrorHandler::DEFAULT_CONTENT => WhoopsErrorHandlerFactory::class, + 'text/html' => WhoopsErrorResponseGeneratorFactory::class, ], ], ], diff --git a/config/autoload/middleware-pipeline.global.php b/config/autoload/middleware-pipeline.global.php index 0e214307..e07149a5 100644 --- a/config/autoload/middleware-pipeline.global.php +++ b/config/autoload/middleware-pipeline.global.php @@ -1,9 +1,30 @@ [ + 'pre-routing' => [ + 'middleware' => [ + ErrorHandler::class, + LocaleMiddleware::class, + ], + 'priority' => 11, + ], + 'pre-routing-rest' => [ + 'path' => '/rest', + 'middleware' => [ + PathVersionMiddleware::class, + ], + 'priority' => 11, + ], + 'routing' => [ 'middleware' => [ ApplicationFactory::ROUTING_MIDDLEWARE, @@ -11,6 +32,16 @@ return [ 'priority' => 10, ], + 'rest' => [ + 'path' => '/rest', + 'middleware' => [ + CrossDomainMiddleware::class, + BodyParserMiddleware::class, + CheckAuthenticationMiddleware::class, + ], + 'priority' => 5, + ], + 'post-routing' => [ 'middleware' => [ ApplicationFactory::DISPATCH_MIDDLEWARE, diff --git a/module/Common/config/middleware-pipeline.config.php b/module/Common/config/middleware-pipeline.config.php deleted file mode 100644 index aab5af85..00000000 --- a/module/Common/config/middleware-pipeline.config.php +++ /dev/null @@ -1,15 +0,0 @@ - [ - 'pre-routing' => [ - 'middleware' => [ - Middleware\LocaleMiddleware::class, - ], - 'priority' => 5, - ], - ], - -]; diff --git a/module/Common/test/ConfigProviderTest.php b/module/Common/test/ConfigProviderTest.php index 920e94e4..05b5da49 100644 --- a/module/Common/test/ConfigProviderTest.php +++ b/module/Common/test/ConfigProviderTest.php @@ -23,7 +23,6 @@ class ConfigProviderTest extends TestCase { $config = $this->configProvider->__invoke(); - $this->assertArrayHasKey('middleware_pipeline', $config); $this->assertArrayHasKey('dependencies', $config); $this->assertArrayHasKey('twig', $config); } diff --git a/module/Rest/config/middleware-pipeline.config.php b/module/Rest/config/middleware-pipeline.config.php deleted file mode 100644 index 19f20198..00000000 --- a/module/Rest/config/middleware-pipeline.config.php +++ /dev/null @@ -1,25 +0,0 @@ - [ - 'pre-routing' => [ - 'path' => '/rest', - 'middleware' => [ - Middleware\PathVersionMiddleware::class, - ], - 'priority' => 11, - ], - - 'rest' => [ - 'path' => '/rest', - 'middleware' => [ - Middleware\CrossDomainMiddleware::class, - Middleware\BodyParserMiddleware::class, - Middleware\CheckAuthenticationMiddleware::class, - ], - 'priority' => 5, - ], - ], -]; diff --git a/module/Rest/test/ConfigProviderTest.php b/module/Rest/test/ConfigProviderTest.php index d6aedf79..a512e31a 100644 --- a/module/Rest/test/ConfigProviderTest.php +++ b/module/Rest/test/ConfigProviderTest.php @@ -24,7 +24,6 @@ class ConfigProviderTest extends TestCase $config = $this->configProvider->__invoke(); $this->assertArrayHasKey('error_handler', $config); - $this->assertArrayHasKey('middleware_pipeline', $config); $this->assertArrayHasKey('routes', $config); $this->assertArrayHasKey('dependencies', $config); $this->assertArrayHasKey('translator', $config);