Skip to content

Commit

Permalink
Merge pull request #8 from thecodingmachine/migrate_to_laminas
Browse files Browse the repository at this point in the history
Migrating from Zend Framework to Laminas
  • Loading branch information
moufmouf committed Sep 3, 2020
2 parents 2b56ec3 + 8529bc4 commit b9d14bf
Show file tree
Hide file tree
Showing 24 changed files with 599 additions and 271 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
@@ -1,6 +1,10 @@
language: php
matrix:
include:
- php: 7.4
env: PREFER_LOWEST=""
- php: 7.3
env: PREFER_LOWEST=""
- php: 7.2
env: PREFER_LOWEST=""
- php: 7.1
Expand Down
148 changes: 77 additions & 71 deletions composer.json
@@ -1,73 +1,79 @@
{
"name" : "thecodingmachine/splash-router",
"description" : "Splash is a PHP router. It takes an HTTP request and dispatches it to the appropriate controller.",
"type" : "mouf-library",
"authors" : [{
"name" : "David Négrier",
"email" : "d.negrier@thecodingmachine.com",
"homepage" : "http://mouf-php.com"
}
],
"keywords" : [
"mvc",
"framework",
"mouf",
"splash",
"splash-common"
],
"homepage" : "http://mouf-php.com/packages/mouf/mvc.splash-common",
"license" : [
"MIT"
],
"require" : {
"php" : ">=7.1",
"cache/void-adapter": "^0.3.1",
"doctrine/annotations": "^1.2",
"mouf/utils.common.url-interface" : "^1",
"zendframework/zend-diactoros": "^1.3.9",
"psr/cache": "^1.0",
"psr/http-server-handler": "^1",
"psr/http-server-middleware": "^1",
"psr/http-message": "^1",
"psr/container": "^1",
"psr/log": "^1"
},
"require-dev": {
"phpunit/phpunit": "^7.2.7",
"satooshi/php-coveralls": "^1.1.0",
"mouf/picotainer": "~1.1",
"mnapoli/simplex": "^0.3",
"cache/array-adapter": "^0.4.2",
"squizlabs/php_codesniffer": "^3.3",
"phpstan/phpstan": "^0.10.1",
"maglnet/composer-require-checker": "^1.0",
"bamarni/composer-bin-plugin": "^1.2"
},
"conflict": {
"zendframework/zend-stratigility": "<2.0"
},
"autoload" : {
"psr-4" : {
"TheCodingMachine\\Splash\\" : "src/TheCodingMachine/Splash"
}
},
"autoload-dev" : {
"psr-4" : {
"TheCodingMachine\\Splash\\" : "tests/TheCodingMachine/Splash"
}
},
"scripts": {
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"phpstan": "phpstan analyse src -c phpstan.neon --level=5 --no-progress -vvv",
"post-install-cmd": ["@composer bin all install --ansi"],
"post-update-cmd": ["@composer bin all update --ansi"]
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra" : {
"branch-alias": {
"dev-master": "10.0.x-dev"
}
}
"name": "thecodingmachine/splash-router",
"description": "Splash is a PHP router. It takes an HTTP request and dispatches it to the appropriate controller.",
"type": "mouf-library",
"authors": [
{
"name": "David Négrier",
"email": "d.negrier@thecodingmachine.com",
"homepage": "http://mouf-php.com"
}
],
"keywords": [
"mvc",
"framework",
"mouf",
"splash",
"splash-common"
],
"homepage": "http://mouf-php.com/packages/mouf/mvc.splash-common",
"license": [
"MIT"
],
"require": {
"php": ">=7.1",
"cache/void-adapter": "^0.3.1",
"doctrine/annotations": "^1.2",
"mouf/utils.common.url-interface": "^1",
"laminas/laminas-diactoros": "^1.3.9 || ^2",
"psr/cache": "^1.0",
"psr/http-server-handler": "^1",
"psr/http-server-middleware": "^1",
"psr/http-message": "^1",
"psr/container": "^1",
"psr/log": "^1",
"laminas/laminas-dependency-plugin": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.2.7",
"satooshi/php-coveralls": "^1.1.0",
"mouf/picotainer": "~1.1",
"mnapoli/simplex": "^0.3",
"cache/array-adapter": "^0.4.2",
"squizlabs/php_codesniffer": "^3.3",
"phpstan/phpstan": "^0.10.1",
"maglnet/composer-require-checker": "^1.0",
"bamarni/composer-bin-plugin": "^1.2"
},
"conflict": {
"laminas/laminas-stratigility": "<2.0"
},
"autoload": {
"psr-4": {
"TheCodingMachine\\Splash\\": "src/TheCodingMachine/Splash"
}
},
"autoload-dev": {
"psr-4": {
"TheCodingMachine\\Splash\\": "tests/TheCodingMachine/Splash"
}
},
"scripts": {
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"phpstan": "phpstan analyse src -c phpstan.neon --level=5 --no-progress -vvv",
"post-install-cmd": [
"@composer bin all install --ansi"
],
"post-update-cmd": [
"@composer bin all update --ansi"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "10.0.x-dev"
}
}
}
10 changes: 5 additions & 5 deletions doc/install/standalone.md
Expand Up @@ -26,7 +26,7 @@ All these components are up to you. In this article, we will show you how to get

- [Stash (for a PSR-6 caching library)](http://www.stashphp.com/)
- [Simplex (for a container)](https://github.com/mnapoli/simplex/). Note: Simplex is a Pimple 3 fork that adds compatibility with container-interop and with container-interop/service-providers. This will be hugely useful to speed up container configuration.
- [Stratigility (for PSR-7 middleware piping)](https://github.com/zendframework/zend-stratigility)
- [Stratigility (for PSR-7 middleware piping)](https://github.com/laminas/laminas-stratigility)

Of course, your mileage may vary and you can really use any compatible library here.

Expand All @@ -44,8 +44,8 @@ Here is a typical `composer.json` file to load all dependencies.
"require": {
"thecodingmachine/splash-service-provider": "^10",
"mnapoli/simplex": "~0.2.1",
"zendframework/zend-diactoros": "^1.3",
"zendframework/zend-stratigility": "^2.0",
"laminas/laminas-diactoros": "^1.3",
"laminas/laminas-stratigility": "^2.0",
"tedivm/stash": "~0.14.0",
"thecodingmachine/doctrine-annotations-universal-module": "~1.0",
"thecodingmachine/psr-6-doctrine-bridge-universal-module": "~1.0",
Expand Down Expand Up @@ -106,8 +106,8 @@ $container->set('thecodingmachine.splash.controllers', [
$container->set('root_url', getenv('BASE'));

// Let's get the PSR-7 server, and let's bootstrap it.
$diactorosServer = $container->get(\Zend\Diactoros\Server::class);
$diactorosServer->listen(new \Zend\Stratigility\NoopFinalHandler());
$diactorosServer = $container->get(\Laminas\Diactoros\Server::class);
$diactorosServer->listen(new \Laminas\Stratigility\NoopFinalHandler());
```

The important part here is:
Expand Down
4 changes: 2 additions & 2 deletions doc/mouf_integration/url_routing.md
Expand Up @@ -4,7 +4,7 @@ subTitle:
currentMenu: configuring_routing
---

Since version 7.0, Splash implements a routing system based on [Stratigility](https://github.com/zendframework/zend-stratigility).
Since version 7.0, Splash implements a routing system based on [Stratigility](https://github.com/laminas/laminas-stratigility).

The basics
----------
Expand Down Expand Up @@ -37,6 +37,6 @@ The `Exception` router should always be the last one
Adding your own router into the stack
-------------------------------------

To do so, you just need to create an instance of a middleware. Check the [Stratigility](https://github.com/zendframework/zend-stratigility) documentation.
To do so, you just need to create an instance of a middleware. Check the [Stratigility](https://github.com/laminas/laminas-stratigility) documentation.

There are many existing PSR-7 middlewares that you can use and add to the pipeline.
2 changes: 1 addition & 1 deletion doc/mouf_integration/writing_controllers.md
Expand Up @@ -80,7 +80,7 @@ Splash makes that very easy to handle. You can just add a @Get or @Post annotati
<?php
namespace Test\Controllers;

use Zend\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use TheCodingMachine\Splash\Annotations\URL;

/**
Expand Down
6 changes: 3 additions & 3 deletions doc/writing_controllers_manually.md
Expand Up @@ -166,15 +166,15 @@ Returning / outputting values
-----------------------------

As you probably already guessed, you must return a [PSR-7 Response object](http://www.php-fig.org/psr/psr-7/#3-3-psr-http-message-responseinterface).
Splash comes bundled with [Zend Diactoros](https://github.com/zendframework/zend-diactoros)
Splash comes bundled with [Zend Diactoros](https://github.com/laminas/laminas-diactoros)

Therefore, you can write things like:

```php
<?php
use TheCodingMachine\Splash\Annotations\URL;
use Zend\Diactoros\Response\HtmlResponse;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;

class MyController {

Expand Down
Expand Up @@ -5,8 +5,8 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TheCodingMachine\Splash\Exception\BadRequestException;
use Zend\Diactoros\Response\HtmlResponse;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;

class BadRequestController implements Http400HandlerInterface
{
Expand Down
Expand Up @@ -7,7 +7,7 @@
use TheCodingMachine\Splash\Utils\SplashException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\Response\RedirectResponse;

/**
* Filter that will bring the user back to HTTP if the user is in HTTPS.
Expand Down
Expand Up @@ -7,7 +7,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TheCodingMachine\Splash\Utils\SplashException;
use Zend\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\Response\RedirectResponse;

/**
* Filter that requires the use of HTTPS (if enabled in the conf)
Expand Down
2 changes: 1 addition & 1 deletion src/TheCodingMachine/Splash/Routers/SplashRouter.php
Expand Up @@ -22,7 +22,7 @@
use Psr\Log\LoggerInterface;
use TheCodingMachine\Splash\Services\SplashUtils;
use Psr\Log\NullLogger;
use Zend\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\Response\RedirectResponse;

class SplashRouter implements MiddlewareInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/TheCodingMachine/Splash/Services/SplashUtils.php
Expand Up @@ -4,7 +4,7 @@

use TheCodingMachine\Splash\Utils\SplashException;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\HtmlResponse;

class SplashUtils
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TheCodingMachine/Splash/Fixtures/TestAction.php
Expand Up @@ -9,7 +9,7 @@
use TheCodingMachine\Splash\Annotations\Put;
use TheCodingMachine\Splash\Annotations\Title;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\JsonResponse;
use TheCodingMachine\Splash\Annotations\URL;

class TestAction
Expand Down
Expand Up @@ -9,7 +9,7 @@
use TheCodingMachine\Splash\Annotations\Put;
use TheCodingMachine\Splash\Annotations\Title;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\JsonResponse;
use TheCodingMachine\Splash\Annotations\URL;

class TestBadParamController
Expand Down
2 changes: 1 addition & 1 deletion tests/TheCodingMachine/Splash/Fixtures/TestController2.php
Expand Up @@ -9,7 +9,7 @@
use TheCodingMachine\Splash\Annotations\Put;
use TheCodingMachine\Splash\Annotations\Title;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\JsonResponse;
use TheCodingMachine\Splash\Annotations\URL;

class TestController2
Expand Down
2 changes: 1 addition & 1 deletion tests/TheCodingMachine/Splash/Fixtures/TestController3.php
Expand Up @@ -9,7 +9,7 @@
use TheCodingMachine\Splash\Annotations\Put;
use TheCodingMachine\Splash\Annotations\Title;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\JsonResponse;
use TheCodingMachine\Splash\Annotations\URL;

class TestController3
Expand Down
Expand Up @@ -9,7 +9,7 @@
use TheCodingMachine\Splash\Annotations\Put;
use TheCodingMachine\Splash\Annotations\Title;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\JsonResponse;
use TheCodingMachine\Splash\Annotations\URL;

class TestExtendedController2 extends TestController2
Expand Down
Expand Up @@ -2,7 +2,7 @@

namespace TheCodingMachine\Splash\Fixtures;

use Zend\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use TheCodingMachine\Splash\Annotations\URL;

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/TheCodingMachine/Splash/Routers/SplashRouterTest.php
Expand Up @@ -22,10 +22,10 @@
use TheCodingMachine\Splash\Utils\SplashException;
use Mouf\Picotainer\Picotainer;
use Psr\Cache\CacheItemPoolInterface;
use Zend\Diactoros\Response\HtmlResponse;
use Zend\Diactoros\Response\JsonResponse;
use Zend\Diactoros\Response\RedirectResponse;
use Zend\Diactoros\ServerRequest;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\ServerRequest;
use TheCodingMachine\Splash\Fixtures\TestController3;

class SplashRouterTest extends TestCase
Expand Down
Expand Up @@ -5,7 +5,7 @@
use PHPUnit\Framework\TestCase;
use TheCodingMachine\Splash\Fixtures\TestController2;
use ReflectionMethod;
use Zend\Diactoros\ServerRequest;
use Laminas\Diactoros\ServerRequest;

class ParameterFetcherRegistryTest extends TestCase
{
Expand Down
Expand Up @@ -4,8 +4,8 @@

use PHPUnit\Framework\TestCase;
use TheCodingMachine\Splash\Exception\SplashMissingParameterException;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\UploadedFile;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\UploadedFile;

class SplashRequestContextTest extends TestCase
{
Expand Down
Expand Up @@ -4,7 +4,7 @@

use PHPUnit\Framework\TestCase;
use TheCodingMachine\Splash\Fixtures\TestController;
use Zend\Diactoros\ServerRequest;
use Laminas\Diactoros\ServerRequest;

class SplashRequestFetcherTest extends TestCase
{
Expand Down
Expand Up @@ -5,7 +5,7 @@
use PHPUnit\Framework\TestCase;
use TheCodingMachine\Splash\Fixtures\TestController;
use ReflectionMethod;
use Zend\Diactoros\ServerRequest;
use Laminas\Diactoros\ServerRequest;

class SplashRequestParameterFetcherTest extends TestCase
{
Expand Down

0 comments on commit b9d14bf

Please sign in to comment.