Ok, I installed a new zend-expressive skeleton project with the following command:
composer create-project zendframework/zend-expressive-skeleton
These are my dependency with composer show:
container-interop/container-interop 1.2.0 Promoting the interoperability of container objects (DIC, SL, etc.)
doctrine/instantiator 1.1.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
fig/http-message-util 1.1.2 Utility classes and constants for use with PSR-7 (psr/http-message)
http-interop/http-middleware 0.4.1 Common interface for HTTP server-side middleware
mtymek/blast-base-url 0.2.0 PSR-7 middleware and helpers for working with base URL.
myclabs/deep-copy 1.7.0 Create deep copies (clones) of your objects
phar-io/manifest 1.0.1 Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version 1.0.1 Library for handling version information and constraints
phpdocumentor/reflection-common 1.0.1 Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock 4.3.0 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve in...
phpdocumentor/type-resolver 0.4.0
phpspec/prophecy 1.7.5 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage 5.3.0 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator 1.4.5 FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template 1.2.1 Simple template engine.
phpunit/php-timer 1.0.9 Utility class for timing
phpunit/php-token-stream 2.0.2 Wrapper around PHPs tokenizer extension
phpunit/phpunit 6.5.7 The PHP Unit Testing framework.
phpunit/phpunit-mock-objects 5.0.6 Mock Object library for PHPUnit
psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11)
psr/http-message 1.0.1 Common interface for HTTP messages
roave/security-advisories dev-master 664836e Prevents installation of composer packages with known security vulnerabilities: no API, simply require it
sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to
sebastian/comparator 2.1.3 Provides the functionality to compare PHP values for equality
sebastian/diff 2.0.1 Diff implementation
sebastian/environment 3.1.0 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 3.1.0 Provides the functionality to export PHP variables for visualization
sebastian/global-state 2.0.0 Snapshotting of global state
sebastian/object-enumerator 3.0.3 Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector 1.1.1 Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context 3.0.0 Provides functionality to recursively process PHP variables
sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources
sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects
squizlabs/php_codesniffer 2.9.1 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding...
symfony/console v4.0.6 Symfony Console Component
symfony/polyfill-mbstring v1.7.0 Symfony polyfill for the Mbstring extension
theseer/tokenizer 1.1.0 A small library for converting tokenized PHP source code into XML and potentially other formats
webimpress/composer-extra-dependency 0.2.2 Composer plugin to require extra dependencies
webimpress/http-middleware-compatibility 0.1.4 Compatibility library for Draft PSR-15 HTTP Middleware
webmozart/assert 1.3.0 Assertions to validate method input/output with nice error messages.
zendframework/zend-code 3.3.0 provides facilities to generate arbitrary code using an object oriented interface
zendframework/zend-component-installer 1.1.1 Composer plugin for automating component registration in zend-mvc and Expressive applications
zendframework/zend-config-aggregator 1.1.0 Lightweight library for collecting and merging configuration from different sources
zendframework/zend-diactoros 1.7.1 PSR HTTP Message implementations
zendframework/zend-escaper 2.5.2
zendframework/zend-eventmanager 3.2.0 Trigger and listen to events within a PHP application
zendframework/zend-expressive 2.1.0 PSR-7 Middleware Microframework based on Stratigility
zendframework/zend-expressive-helpers 4.2.0 Helper/Utility classes for Expressive
zendframework/zend-expressive-router 2.4.1 Router subcomponent for Expressive
zendframework/zend-expressive-template 1.0.4 Template subcomponent for Expressive
zendframework/zend-expressive-tooling 0.4.6 Migration and development tooling for Expressive
zendframework/zend-expressive-zendrouter 2.2.0 zend-mvc router support for Expressive
zendframework/zend-http 2.7.0 provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests
zendframework/zend-loader 2.5.1
zendframework/zend-psr7bridge 1.0.2 PSR-7 <-> zend-http message conversions
zendframework/zend-router 3.0.2
zendframework/zend-servicemanager 3.3.2 Factory-Driven Dependency Injection Container
zendframework/zend-stdlib 3.1.0
zendframework/zend-stratigility 2.1.2 Middleware for PHP
zendframework/zend-uri 2.5.2 a component that aids in manipulating and validating
zendframework/zend-validator 2.10.2 provides a set of commonly needed validators
zfcampus/zf-composer-autoloading 2.0.0 Sets up Composer-based autoloading for your Zend Framework modules
zfcampus/zf-development-mode 3.1.0 Zend Framework development mode script
If I use the programmatic way of injecting pipeline and routes through the files pipeline.php and routes.php all works, but the moment I use the method $app->injectRoutesFromConfig($container->get('config'));
inside an application delegator this is the error that I see:
Deprecated: Zend\Expressive\Router\Route will not accept anything other than objects implementing the MiddlewareInterface starting in version 3.0.0; we detected usage of "array" for path "/api/ping" using methods GET. Please update your code to create middleware instances implementing MiddlewareInterface; use decorators for callable middleware if needed. in /var/www/html/vendor/zendframework/zend-expressive-router/src/Route.php on line 296
This is the ConfigProvider.php:
public function getRoutesConfig() {
return [
[
'name' => 'api.ping',
'path' => '/api/ping',
'middleware' => [
Action\PingAction::class
],
'allowed_methods' => ['GET']
]
];
}
This is the ApplicationDelegator.php:
<?php
/**
* container-interop-doctrine
*
* @link http://github.com/DASPRiD/container-interop-doctrine For the canonical source repository
* @copyright 2016 Ben Scholzen 'DASPRiD'
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace App;
use Psr\Container\ContainerInterface;
use Zend\Expressive\Helper\ServerUrlMiddleware;
use Zend\Expressive\Helper\UrlHelperMiddleware;
use Zend\Expressive\Middleware\ImplicitHeadMiddleware;
use Zend\Expressive\Middleware\ImplicitOptionsMiddleware;
use Zend\Expressive\Middleware\NotFoundHandler;
use Zend\Stratigility\Middleware\ErrorHandler;
class ApplicationDelegatorFactory {
/**
* @param ContainerInterface $container
* @param string $serviceName Name of the service being created.
* @param callable $callback Creates and returns the service.
* @return Application
*/
public function __invoke(ContainerInterface $container, $serviceName, callable $callback) {
/** @var $app Application */
$app = $callback();
/**
* Setup middleware pipeline:
*/
/** @var \Zend\Expressive\Application $app */
// The error handler should be the first (most outer) middleware to catch
// all Exceptions.
$app->pipe(\Blast\BaseUrl\BaseUrlMiddleware::class);
$app->pipe(ErrorHandler::class);
$app->pipe(ServerUrlMiddleware::class);
// Pipe more middleware here that you want to execute on every request:
// - bootstrapping
// - pre-conditions
// - modifications to outgoing responses
//
// Piped Middleware may be either callables or service names. Middleware may
// also be passed as an array; each item in the array must resolve to
// middleware eventually (i.e., callable or service name).
//
// Middleware can be attached to specific paths, allowing you to mix and match
// applications under a common domain. The handlers in each middleware
// attached this way will see a URI with the MATCHED PATH SEGMENT REMOVED!!!
//
// - $app->pipe('/api', $apiMiddleware);
// - $app->pipe('/docs', $apiDocMiddleware);
// - $app->pipe('/files', $filesMiddleware);
// Register the routing middleware in the middleware pipeline
$app->pipeRoutingMiddleware();
$app->pipe(ImplicitHeadMiddleware::class);
$app->pipe(ImplicitOptionsMiddleware::class);
$app->pipe(UrlHelperMiddleware::class);
// Add more middleware here that needs to introspect the routing results; this
// might include:
//
// - route-based authentication
// - route-based validation
// - etc.
// Register the dispatch middleware in the middleware pipeline
$app->pipeDispatchMiddleware();
// At this point, if no Response is returned by any middleware, the
// NotFoundHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
$app->pipe(NotFoundHandler::class);
/**
* Setup routes with a single request method:
*/
$app->injectRoutesFromConfig($container->get('config'));
return $app;
}
}