1. Go to this page and download the library: Download linio/common-expressive library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
linio / common-expressive example snippets
declare(strict_types=1);
use Interop\Container\ContainerInterface;
return [
// Provides application-wide services.
// We recommend using fully-qualified class names whenever possible as
// service names.
'dependencies' => [
// Use 'invokables' for constructor-less services, or services that do
// not 'factories' => [
\Zend\Expressive\Application::class => \Zend\Expressive\Container\ApplicationFactory::class,
\Zend\Expressive\Helper\UrlHelper::class => \Zend\Expressive\Helper\UrlHelperFactory::class,
\Particle\Validator\Validator::class => function (ContainerInterface $container) {
return new \Particle\Validator\Validator();
},
\Linio\Common\Expressive\Validation\ValidatorFactory::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Validation\ValidatorFactory(
$container,
\Particle\Validator\Validator::class
);
},
\Linio\Common\Expressive\Validation\ValidationRulesFactory::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Validation\ValidationRulesFactory($container);
},
\Linio\Common\Expressive\Validation\ValidationService::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Validation\ValidationService(
$container->get(\Linio\Common\Expressive\Validation\ValidatorFactory::class),
$container->get(\Linio\Common\Expressive\Validation\ValidationRulesFactory::class)
);
},
\Linio\Common\Expressive\Filter\FilterRulesFactory::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Filter\FilterRulesFactory($container);
},
\Linio\Common\Expressive\Filter\FilterService::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Filter\FilterService(
\Particle\Filter\Filter::class,
$container->get(\Linio\Common\Expressive\Filter\FilterRulesFactory::class)
);
},
],
'shared' => [
\Particle\Validator\Validator::class => false,
],
],
];
declare(strict_types=1);
use Interop\Container\ContainerInterface;
return [
'dependencies' => [
'invokables' => [
\Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware::class => \Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware::class,
\Linio\Common\Expressive\Middleware\ConvertErrorToJsonResponse::class => \Linio\Common\Expressive\Middleware\ConvertErrorToJsonResponse::class,
\Linio\Common\Expressive\Middleware\AddRequestIdToRequest::class => \Linio\Common\Expressive\Middleware\AddRequestIdToRequest::class,
\Linio\Common\Expressive\Middleware\AddRequestIdToResponse::class => \Linio\Common\Expressive\Middleware\AddRequestIdToResponse::class,
\Linio\Common\Expressive\Middleware\LogExceptions::class => \Linio\Common\Expressive\Middleware\LogExceptions::class,
],
'factories' => [
\Zend\Expressive\Helper\ServerUrlMiddleware::class => \Zend\Expressive\Helper\ServerUrlMiddlewareFactory::class,
\Zend\Expressive\Helper\UrlHelperMiddleware::class => \Zend\Expressive\Helper\UrlHelperMiddlewareFactory::class,
\Linio\Common\Expressive\Middleware\ValidateRequestBody::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Middleware\ValidateRequestBody(
$container->get(\Linio\Common\Expressive\Validation\ValidationService::class), $container->get('config')['routes']
);
},
\Linio\Common\Expressive\Middleware\LogRequest::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Middleware\LogRequest(
$container->get(\Linio\Common\Expressive\Logging\LogRequestResponseService::class)
);
},
\Linio\Common\Expressive\Middleware\LogResponse::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Middleware\LogResponse(
$container->get(\Linio\Common\Expressive\Logging\LogRequestResponseService::class)
);
},
\Linio\Common\Expressive\Middleware\ConfigureNewrelicForRequest::class => function (ContainerInterface $container) {
$config = $container->get('config');
return new \Linio\Common\Expressive\Middleware\ConfigureNewrelicForRequest($config['logging']['newRelic']['appName']);
},
\Linio\Common\Expressive\Middleware\ValidateSupportedContentTypes::class => function (ContainerInterface $container) {
return new \Linio\Common\Expressive\Middleware\ValidateSupportedContentTypes(\Linio\Common\Expressive\Middleware\ValidateSupportedContentTypes::DEFAULT_CONTENT_TYPES);
},
],
],
// This can be used to seed pre- and/or post-routing middleware
'middleware_pipeline' => [
'always' => [
'middleware' => [
// Add more middleware here that you want to execute on
// every request:
// - bootstrapping
// - pre-conditions
// - modifications to outgoing responses
\Zend\Expressive\Helper\ServerUrlMiddleware::class,
\Linio\Common\Expressive\Middleware\AddRequestIdToRequest::class,
\Linio\Common\Expressive\Middleware\AddRequestIdToLog::class,
\Linio\Common\Expressive\Middleware\LogResponse::class,
\Linio\Common\Expressive\Middleware\AddRequestIdToResponse::class,
\Linio\Common\Expressive\Middleware\LogRequest::class,
],
'priority' => 10000,
],
'routing' => [
'middleware' => [
\Zend\Expressive\Container\ApplicationFactory::ROUTING_MIDDLEWARE,
\Zend\Expressive\Helper\UrlHelperMiddleware::class,
\Linio\Common\Expressive\Middleware\ValidateSupportedContentTypes::class,
\Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware::class,
\Linio\Common\Expressive\Middleware\ConfigureNewrelicForRequest::class,
\Linio\Common\Expressive\Middleware\ValidateRequestBody::class,
// Add more middleware here that needs to introspect the routing
// results; this might