Giter Club home page Giter Club logo

mezzio-fastroute's Introduction

mezzio

Build Status Type Coverage

Develop PSR-7 middleware applications in minutes!

mezzio builds on laminas-stratigility to provide a minimalist PSR-7 middleware framework for PHP, with the following features:

Installation

We provide two ways to install Mezzio, both using Composer: via our skeleton project and installer, or manually.

Using the skeleton + installer

The simplest way to install and get started is using the skeleton project, which includes installer scripts for choosing a router, dependency injection container, and optionally a template renderer and/or error handler. The skeleton also provides configuration for officially supported dependencies.

To use the skeleton, use Composer's create-project command:

composer create-project mezzio/mezzio-skeleton <project dir>

This will prompt you through choosing your dependencies, and then create and install the project in the <project dir> (omitting the <project dir> will create and install in a mezzio-skeleton/ directory).

Manual Composer installation

You can install Mezzio standalone using Composer:

composer require mezzio/mezzio

However, at this point, Mezzio is not usable, as you need to supply minimally:

  • a router.
  • a dependency injection container.

We currently support and provide the following routing integrations:

We recommend using a dependency injection container, and typehint against PSR-11 Container. We can recommend the following implementations:

  • laminas-servicemanager: composer require laminas/laminas-servicemanager
  • Pimple (see docs for more details): composer require laminas/laminas-pimple-config
  • Aura.Di (see docs for more details): composer require laminas/laminas-auradi-config

Additionally, you may optionally want to install a template renderer implementation, and/or an error handling integration. These are covered in the documentation.

Documentation

Documentation is in the doc tree, and can be compiled using mkdocs:

mkdocs build

Additionally, public-facing, browseable documentation is available at https://docs.mezzio.dev/mezzio/

mezzio-fastroute's People

Contributors

acidvertigo avatar arueckauer avatar bakura10 avatar boesing avatar fezfez avatar geerteltink avatar ghostwriter avatar gsteel avatar harikt avatar koopzington avatar laminas-bot avatar lcobucci avatar marcelthole avatar michalbundyra avatar ocramius avatar pine3ree avatar powerkiki avatar renanbr avatar renovate[bot] avatar rodmcnew avatar samsonasik avatar sandrokeil avatar snapshotpl avatar tommyseus avatar weierophinney avatar xerkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mezzio-fastroute's Issues

Psalm integration

Feature Request

Q A
QA yes

Summary

As decided during the Technical-Steering-Committee Meeting on August 3rd, 2020, Laminas wants to implement vimeo/psalm in all packages.

Implementing psalm is quite easy.

Required

  • Create a psalm.xml in the project root
  • Copy and paste the contents from this psalm.xml.dist
  • Run $ composer require --dev vimeo/psalm
  • Run $ vendor/bin/psalm --set-baseline=psalm-baseline.xml
  • Add a composer script static-analysis with the command psalm --shepherd --stats
  • Add a new line to script: in .travis.yml: - if [[ $TEST_COVERAGE == 'true' ]]; then composer static-analysis ; fi
  • Remove phpstan from the project (phpstan.neon.dist, .travis.yml entry, composer.json require-dev and scripts)
Optional
  • Fix as many psalm errors as possible.

`FastRouteRouter#getCacheFile` to provide cache location

Feature Request

Q A
New Feature yes
BC Break no

Summary

I am writing a command with laminas-cli in our project to remove cache files.
There is actually no way of receiving the default cache location of the FastRouteRouter. The only thing I can do as of now is to pass the config file path by myself but it would be quite helpful if this would be provided by this component.

Another idea could be a mezzio/mezzio command to flush the configuration cache. Sadly, the config cache path is not passed to the config itself by default and thus, its not that easy.
However, together with the command-chain feature of laminas-cli, a generic command to flush all application caches could be provided as well, but this is not feasible as of now.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Use matchDepNames instead of matchPackageNames

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

composer
composer.json
  • php ~8.1.0 || ~8.2.0 || ~8.3.0
  • fig/http-message-util ^1.1.2
  • laminas/laminas-stdlib ^3.1
  • mezzio/mezzio-router ^3.14
  • nikic/fast-route ^1.2
  • psr/container ^1.0 || ^2.0
  • psr/http-message ^1.0.1 || ^2.0.0
  • laminas/laminas-coding-standard ~2.5.0
  • laminas/laminas-diactoros ^3.3.0
  • laminas/laminas-stratigility ^3.11
  • mikey179/vfsstream ^1.6.11
  • phpunit/phpunit ^10.5.9
  • psalm/plugin-phpunit ^0.19.0
  • vimeo/psalm ^5.21.1
github-actions
.github/workflows/continuous-integration.yml
.github/workflows/release-on-milestone-closed.yml

  • Check this box to trigger a request for Renovate to run again on this repository

FastRouteRouter->addRoute() does not throw a RuntimeException of called after either match() or geerateUri()

The Zend\Expressive\Router\RouterInface states on addRoute():

    /**
     * ...
     *
     * The method MUST raise Exception\RuntimeException if called after either `match()`
     * or `generateUri()` have already been called, to ensure integrity of the
     * router between invocations of either of those methods.
     *
     * @throws Exception\RuntimeException when called after match() or
     *     generateUri() have been called.
     */
    public function addRoute(Route $route) : void;

But no RuntimeException will be thrown / raised.

Code to reproduce the issue

class TestMiddleware implements \Psr\Http\Server\MiddlewareInterface
{
  public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
    return $handler->handle($request);
  }
}

$router = new \Zend\Expressive\Router\FastRouteRouter();
$router->addRoute('/test', new TestMiddleware());
$router->match($request);
$router->addRoute('/test2', new TestMiddleware());

Expected results

A Zend\Expressive\Router\Exception\RuntimeException is thrown indicating that no routes may be added after calling match().

Actual results

Scripts run without an exception.

Consequences

Is this a bug in the RouterInterface of "zend-expressive-router" or in the FastRouteRouter of this repo?
(Same "error" (?) is in the "zend-expressive-zendrouter").


Originally posted by @MatthiasKuehneEllerhold at zendframework/zend-expressive-fastroute#60

PHP 8.0 support

Feature Request

Q A
New Feature yes

Summary

To be prepared for the december release of PHP 8.0, this repository has some additional TODOs to be tested against the new major version.

In order to make this repository compatible, one has to follow these steps:

  • Modify composer.json to provide support for PHP 8.0 by adding the constraint ~8.0.0
  • Modify composer.json to drop support for PHP less than 7.3
  • Modify composer.json to implement phpunit 9.3 which supports PHP 7.3+
  • Modify .travis.yml to ignore platform requirements when installing composer dependencies (simply add --ignore-platform-reqs to COMPOSER_ARGS env variable)
  • Modify .travis.yml to add PHP 8.0 to the matrix (NOTE: Do not allow failures as PHP 8.0 has a feature freeze since 2020-08-04!)
  • Modify source code in case there are incompatibilities with PHP 8.0

Route option values should be retrievable from request attribute

Provide a narrative description of what you are trying to accomplish.

Code to reproduce the issue

Given this route configuration

$app->post('/api/commands/register-user', [
        \Prooph\ProophessorDo\Middleware\JsonPayload::class,
        \Prooph\ProophessorDo\Middleware\JsonError::class,
        \Prooph\HttpMiddleware\CommandMiddleware::class,
    ], 'command::register-user')
        ->setOptions([
            'values' => [
                'prooph_command_name' => \Prooph\ProophessorDo\Model\User\Command\RegisterUser::class,
            ],
        ]);

in \Prooph\HttpMiddleware\CommandMiddleware::class

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
    $commandName = $request->getAttribute(self::NAME_ATTRIBUTE);
    var_dump($commandName);
    // null

Expected results

Route option values should set as request attribute

Actual results

Request attribute is not passed

This works with the aurarouter. Switching the router makes this bug appear.

prooph/proophessor-do#162

ra/router                                    3.1.0              Powerful, flexible web routing for PSR-7 requests.
beberlei/assert                                v2.9.3             Thin assertion library for input validation in business models.
composer/semver                                1.4.2              Semver library that offers utilities, version constraint parsing and validation.
container-interop/container-interop            1.2.0              Promoting the interoperability of container objects (DIC, SL, etc.)
doctrine/annotations                           v1.6.0             Docblock Annotations Parser
doctrine/cache                                 v1.7.1             Caching library offering an object-oriented API for many cache backends
doctrine/collections                           v1.5.0             Collections Abstraction library
doctrine/common                                v2.8.1             Common Library for Doctrine projects
doctrine/dbal                                  v2.6.3             Database Abstraction Layer
doctrine/inflector                             v1.3.0             Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                          1.1.0              A small, lightweight utility to instantiate objects in PHP without invoking their...
doctrine/lexer                                 v1.0.1             Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
fig/http-message-util                          1.1.2              Utility classes and constants for use with PSR-7 (psr/http-message)
filp/whoops                                    2.1.14             php error handling for cool kids
friendsofphp/php-cs-fixer                      v2.11.1            A tool to automatically fix PHP code style
guzzlehttp/guzzle                              6.3.2              Guzzle is a PHP HTTP client library
guzzlehttp/promises                            v1.3.1             Guzzle promises library
guzzlehttp/psr7                                1.4.2              PSR-7 message implementation that also provides common utility methods
malukenho/docheader                            0.1.7              A small library to check header docs
marc-mabe/php-enum                             v3.0.0             Simple and fast implementation of enumerations with native PHP>=5.6
myclabs/deep-copy                              1.7.0              Create deep copies (clones) of your objects
nikic/fast-route                               v1.3.0             Fast request router for PHP
paragonie/random_compat                        v2.0.11            PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
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
php-coveralls/php-coveralls                    v2.0.0             PHP client library for Coveralls API
php-cs-fixer/diff                              v1.3.0             sebastian/diff v2 backport support for PHP5.6
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 ...
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...
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 PHP's tokenizer extension.
phpunit/phpunit                                6.5.7              The PHP Unit Testing framework.
phpunit/phpunit-mock-objects                   5.0.6              Mock Object library for PHPUnit
prooph/common                                  v4.2.2             Common classes used across prooph packages
prooph/event-sourcing                          v5.3.0             PHP EventSourcing library
prooph/event-store                             v7.3.3             PHP EventStore Implementation
prooph/event-store-bus-bridge                  v3.1.0             Marry CQRS with Event Sourcing
prooph/event-store-http-middleware             v0.2.0             PSR-15 EventStore HTTP Middleware
prooph/http-middleware                         v0.1.0             http middleware for prooph components
prooph/pdo-event-store                         v1.7.3             Prooph PDO EventStore
prooph/php-cs-fixer-config                     v0.2.1             PHP CS Fixer config for prooph components
prooph/service-bus                             v6.2.2             PHP Enterprise Service Bus Implementation supporting CQRS and DDD
proophsoftware/prooph-cli                      v0.2.0             prooph components command line tool for rapid development
psr/container                                  1.0.0              Common Container Interface (PHP FIG PSR-11)
psr/http-message                               1.0.1              Common interface for HTTP messages
psr/http-server-handler                        1.0.0              Common interface for HTTP server-side request handler
psr/http-server-middleware                     1.0.0              Common interface for HTTP server-side middleware
psr/log                                        1.0.2              Common interface for logging libraries
ramsey/uuid                                    3.7.3              Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4...
react/promise                                  v2.5.1             A lightweight implementation of CommonJS Promises/A for PHP
roave/security-advisories                      dev-master 4a272b6 Prevents installation of composer packages with known security vulnerabilities: n...
sandrokeil/interop-config                      2.1.0              Provides interfaces and a concrete implementation to create instances depending o...
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
symfony/config                                 v4.0.6             Symfony Config Component
symfony/console                                v3.4.6             Symfony Console Component
symfony/debug                                  v4.0.6             Symfony Debug Component
symfony/event-dispatcher                       v4.0.6             Symfony EventDispatcher Component
symfony/filesystem                             v4.0.6             Symfony Filesystem Component
symfony/finder                                 v4.0.6             Symfony Finder Component
symfony/options-resolver                       v4.0.6             Symfony OptionsResolver Component
symfony/polyfill-mbstring                      v1.7.0             Symfony polyfill for the Mbstring extension
symfony/polyfill-php70                         v1.7.0             Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72                         v1.7.0             Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/process                                v4.0.6             Symfony Process Component
symfony/stopwatch                              v4.0.6             Symfony Stopwatch Component
symfony/yaml                                   v4.0.6             Symfony Yaml Component
theseer/tokenizer                              1.1.0              A small library for converting tokenized PHP source code into XML and potentially...
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-config                      3.1.0              provides a nested object property based user interface for accessing this configu...
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                  3.0.1              PSR-15 Middleware Microframework
zendframework/zend-expressive-fastroute        3.0.1              FastRoute integration for Expressive
zendframework/zend-expressive-helpers          5.0.0              Helper/Utility classes for Expressive
zendframework/zend-expressive-router           3.0.2              Router subcomponent for Expressive
zendframework/zend-expressive-template         2.0.0              Template subcomponent for Expressive
zendframework/zend-expressive-zendviewrenderer 2.0.0              zend-view PhpRenderer integration for Expressive
zendframework/zend-filter                      2.7.2              provides a set of commonly needed data filters
zendframework/zend-httphandlerrunner           1.0.1              Execute PSR-15 RequestHandlerInterface instances and emit responses they generate.
zendframework/zend-loader                      2.5.1             
zendframework/zend-mail                        2.9.0              provides generalized functionality to compose and send both text and MIME-complia...
zendframework/zend-mime                        2.7.0              Create and parse MIME messages and parts
zendframework/zend-servicemanager              3.3.2              Factory-Driven Dependency Injection Container
zendframework/zend-stdlib                      3.1.0             
zendframework/zend-stratigility                3.0.0              PSR-7 middleware foundation for building and dispatching middleware pipelines
zendframework/zend-validator                   2.10.2             provides a set of commonly needed validators
zendframework/zend-view                        2.10.0             provides a system of helpers, output filters, and variable escaping
zfcampus/zf-development-mode                   3.1.0              Zend Framework development mode script

Originally posted by @basz at zendframework/zend-expressive-fastroute#58

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.