From 0d2239298a72afb5888de952f0a3d5158c3b023d Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 5 Oct 2017 15:39:23 +0100 Subject: [PATCH] Initial commit --- .gitattributes | 5 +++ .gitignore | 2 + .travis.yml | 38 +++++++++++++++++ CODE_OF_CONDUCT.md | 43 +++++++++++++++++++ LICENSE.md | 23 ++++++++++ README.md | 72 ++++++++++++++++++++++++++++++++ autoload/http-middleware.php | 54 ++++++++++++++++++++++++ composer.json | 39 +++++++++++++++++ phpunit.xml.dist | 11 +++++ test/HandlerInterfaceTest.php | 48 +++++++++++++++++++++ test/MiddlewareInterfaceTest.php | 43 +++++++++++++++++++ 11 files changed, 378 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 autoload/http-middleware.php create mode 100644 composer.json create mode 100644 phpunit.xml.dist create mode 100644 test/HandlerInterfaceTest.php create mode 100644 test/MiddlewareInterfaceTest.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b8509b0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +/test export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c55784d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +composer.lock +/vendor/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..46a29f3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,38 @@ +sudo: false + +language: php + +cache: + directories: + - $HOME/.composer/cache + - vendor + +env: + - HTTP_MIDDLEWARE_VERSION="^0.1.1" + - HTTP_MIDDLEWARE_VERSION="^0.2" + - HTTP_MIDDLEWARE_VERSION="^0.3" + - HTTP_MIDDLEWARE_VERSION="^0.4.1" + - HTTP_MIDDLEWARE_VERSION="^0.5" + - HTTP_MIDDLEWARE_VERSION="dev-master" + +php: + - 5.6 + - 7.0 + - 7.1 + - 7.2 + +before_install: + - phpenv config-rm xdebug.ini || return 0 + - travis_retry composer self-update + +install: + - travis_retry composer require --no-interaction http-interop/http-middleware:$HTTP_MIDDLEWARE_VERSION + - travis_retry composer install --no-interaction + - if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update --no-interaction --with-dependencies phpunit/phpunit ; fi + - stty cols 120 && composer show + +script: + - composer test + +notifications: + email: false diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..02fafcd --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,43 @@ +# Contributor Code of Conduct + +This project adheres to [The Code Manifesto](http://codemanifesto.com) +as its guidelines for contributor interactions. + +## The Code Manifesto + +We want to work in an ecosystem that empowers developers to reach their +potential — one that encourages growth and effective collaboration. A space that +is safe for all. + +A space such as this benefits everyone that participates in it. It encourages +new developers to enter our field. It is through discussion and collaboration +that we grow, and through growth that we improve. + +In the effort to create such a place, we hold to these values: + +1. **Discrimination limits us.** This includes discrimination on the basis of + race, gender, sexual orientation, gender identity, age, nationality, technology + and any other arbitrary exclusion of a group of people. +2. **Boundaries honor us.** Your comfort levels are not everyone’s comfort + levels. Remember that, and if brought to your attention, heed it. +3. **We are our biggest assets.** None of us were born masters of our trade. + Each of us has been helped along the way. Return that favor, when and where + you can. +4. **We are resources for the future.** As an extension of #3, share what you + know. Make yourself a resource to help those that come after you. +5. **Respect defines us.** Treat others as you wish to be treated. Make your + discussions, criticisms and debates from a position of respectfulness. Ask + yourself, is it true? Is it necessary? Is it constructive? Anything less is + unacceptable. +6. **Reactions require grace.** Angry responses are valid, but abusive language + and vindictive actions are toxic. When something happens that offends you, + handle it assertively, but be respectful. Escalate reasonably, and try to + allow the offender an opportunity to explain themselves, and possibly correct + the issue. +7. **Opinions are just that: opinions.** Each and every one of us, due to our + background and upbringing, have varying opinions. The fact of the matter, is + that is perfectly acceptable. Remember this: if you respect your own + opinions, you should respect the opinions of others. +8. **To err is human.** You might not intend it, but mistakes do happen and + contribute to build experience. Tolerate honest mistakes, and don't hesitate + to apologize if you make one yourself. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..63ab8b2 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,23 @@ +Copyright (c) 2017, Michał Bundyra +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e99f3a3 --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# http-middleware-compatibility + +[![Build Status](https://travis-ci.org/webimpress/http-middleware-compatibility.svg?branch=master)](https://travis-ci.org/webimpress/http-middleware-compatibility) + +## Purpose + +The purpose of the library is to deliver consistent interface for different +versions of [`http-interop/http-middleware`](https://github.com/http-interop/http-middleware) +which implements [Draft of PSR-15 HTTP Middleware](https://github.com/php-fig/fig-standards/tree/master/proposed/http-middleware). + +Many projects currently use different version of library +`http-interop/http-middleware` and updating to newest version requires usually +major release. The library lets consumers of your component decide what version +of `http-interop/http-middleware` they want to use and allow them to migrate to +the latest version at any time. + +## Usage + +Your middleware should implement interface `Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface`, +and for delegator/request handler you should use interface +`Webimpress\HttpMiddlewareCompatibility\HandlerInterface`. + +```php +{HANDLER_METHOD}($request); + } +} +``` + +That's it! Now consumers of your component can decide what version of +`http-interop/http-middleware` they want to use. diff --git a/autoload/http-middleware.php b/autoload/http-middleware.php new file mode 100644 index 0000000..6c817fe --- /dev/null +++ b/autoload/http-middleware.php @@ -0,0 +1,54 @@ + + + + + ./test + + + diff --git a/test/HandlerInterfaceTest.php b/test/HandlerInterfaceTest.php new file mode 100644 index 0000000..583d075 --- /dev/null +++ b/test/HandlerInterfaceTest.php @@ -0,0 +1,48 @@ +