Skip to content

Commit 1416965

Browse files
committed
mezzio-postgres
1 parent 6003b1d commit 1416965

39 files changed

+559
-710
lines changed

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# petstore
22

3-
[![CI](https://github.com/chubbyphp/petstore/actions/workflows/ci.yml/badge.svg?branch=chubbyphp)](https://github.com/chubbyphp/petstore/actions/workflows/ci.yml)
4-
[![Coverage Status](https://coveralls.io/repos/github/chubbyphp/petstore/badge.svg?branch=chubbyphp)](https://coveralls.io/github/chubbyphp/petstore?branch=chubbyphp)
5-
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchubbyphp%2Fpetstore%2Fchubbyphp)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/petstore/chubbyphp)
3+
[![CI](https://github.com/chubbyphp/petstore/actions/workflows/ci.yml/badge.svg?branch=mezzio)](https://github.com/chubbyphp/petstore/actions/workflows/ci.yml)
4+
[![Coverage Status](https://coveralls.io/repos/github/chubbyphp/petstore/badge.svg?branch=mezzio)](https://coveralls.io/github/chubbyphp/petstore?branch=mezzio)
5+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchubbyphp%2Fpetstore%mezzio)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/petstore/mezzio)
66

77
## Description
88

9-
A simple skeleton to build api's based on the [chubbyphp-framework][1].
9+
A simple skeleton to build api's based on the [mezzio][1] framework.
1010

1111
## Requirements
1212

1313
* php: ^8.3
1414
* [chubbyphp/chubbyphp-clean-directories][2]: ^1.5.1
1515
* [chubbyphp/chubbyphp-cors][3]: ^1.7.1
1616
* [chubbyphp/chubbyphp-decode-encode][4]: ^1.3.1
17-
* [chubbyphp/chubbyphp-framework][5]: ^6.0.2
18-
* [chubbyphp/chubbyphp-framework-router-fastroute][6]: ^2.3.3
19-
* [chubbyphp/chubbyphp-http-exception][7]: ^1.3.2
20-
* [chubbyphp/chubbyphp-laminas-config][8]: ^1.5.1
21-
* [chubbyphp/chubbyphp-laminas-config-doctrine][9]: ^3.1.1
22-
* [chubbyphp/chubbyphp-laminas-config-factory][10]: ^1.5.1
23-
* [chubbyphp/chubbyphp-negotiation][11]: ^2.3.1
24-
* [chubbyphp/chubbyphp-parsing][12]: ^2.1.2
25-
* [doctrine/orm][13]: ^3.6.1
17+
* [chubbyphp/chubbyphp-http-exception][5]: ^1.3.2
18+
* [chubbyphp/chubbyphp-laminas-config][6]: ^1.5.1
19+
* [chubbyphp/chubbyphp-laminas-config-doctrine][7]: ^3.1
20+
* [chubbyphp/chubbyphp-laminas-config-factory][8]: ^1.5
21+
* [chubbyphp/chubbyphp-negotiation][9]: ^2.3.1
22+
* [chubbyphp/chubbyphp-parsing][10]: ^2.1.2
23+
* [doctrine/orm][11]: ^3.6.1
24+
* [mezzio/mezzio-fastroute][12]: ^3.14
25+
* [mezzio/mezzio][13]: ^3.27
2626
* [monolog/monolog][14]: ^3.10
2727
* [ramsey/uuid][15]: ^4.9.2
2828
* [slim/psr7][16]: ^1.8
@@ -203,19 +203,20 @@ curl -XPUT 'https://admin:98T722Eqw99oqFCSJCnB@localhost:9200/_plugins/_ism/poli
203203

204204
2026 Dominik Zogg
205205

206-
[1]: https://github.com/chubbyphp/chubbyphp-framework
206+
[1]: https://docs.mezzio.dev
207+
207208
[2]: https://packagist.org/packages/chubbyphp/chubbyphp-clean-directories
208209
[3]: https://packagist.org/packages/chubbyphp/chubbyphp-cors
209210
[4]: https://packagist.org/packages/chubbyphp/chubbyphp-decode-encode
210-
[5]: https://packagist.org/packages/chubbyphp/chubbyphp-framework
211-
[6]: https://packagist.org/packages/chubbyphp/chubbyphp-framework-router-fastroute
212-
[7]: https://packagist.org/packages/chubbyphp/chubbyphp-http-exception
213-
[8]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config
214-
[9]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config-doctrine
215-
[10]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config-factory
216-
[11]: https://packagist.org/packages/chubbyphp/chubbyphp-negotiation
217-
[12]: https://packagist.org/packages/chubbyphp/chubbyphp-parsing
218-
[13]: https://packagist.org/packages/doctrine/orm
211+
[5]: https://packagist.org/packages/chubbyphp/chubbyphp-http-exception
212+
[6]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config
213+
[7]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config-doctrine
214+
[8]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config-factory
215+
[9]: https://packagist.org/packages/chubbyphp/chubbyphp-negotiation
216+
[10]: https://packagist.org/packages/chubbyphp/chubbyphp-parsing
217+
[11]: https://packagist.org/packages/doctrine/orm
218+
[12]: https://packagist.org/packages/mezzio/mezzio-fastroute
219+
[13]: https://packagist.org/packages/mezzio/mezzio
219220
[14]: https://packagist.org/packages/monolog/monolog
220221
[15]: https://packagist.org/packages/ramsey/uuid
221222
[16]: https://packagist.org/packages/slim/psr7

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "chubbyphp/petstore",
3-
"description": "A simple skeleton to build api's based on the chubbyphp-framework.",
3+
"description": "A simple skeleton to build api's based on the mezzio framework.",
44
"keywords": [
55
"chubbyphp",
66
"framework",
7+
"mezzio",
78
"skeleton"
89
],
910
"license": "MIT",
@@ -18,15 +19,15 @@
1819
"chubbyphp/chubbyphp-clean-directories": "^1.5.1",
1920
"chubbyphp/chubbyphp-cors": "^1.7.1",
2021
"chubbyphp/chubbyphp-decode-encode": "^1.3.1",
21-
"chubbyphp/chubbyphp-framework": "^6.0.2",
22-
"chubbyphp/chubbyphp-framework-router-fastroute": "^2.3.3",
2322
"chubbyphp/chubbyphp-http-exception": "^1.3.2",
2423
"chubbyphp/chubbyphp-laminas-config": "^1.5.1",
2524
"chubbyphp/chubbyphp-laminas-config-doctrine": "^3.1.1",
2625
"chubbyphp/chubbyphp-laminas-config-factory": "^1.5.1",
2726
"chubbyphp/chubbyphp-negotiation": "^2.3.1",
2827
"chubbyphp/chubbyphp-parsing": "^2.1.2",
2928
"doctrine/orm": "^3.6.1",
29+
"mezzio/mezzio-fastroute": "^3.14",
30+
"mezzio/mezzio": "^3.27",
3031
"monolog/monolog": "^3.10",
3132
"ramsey/uuid": "^4.9.2",
3233
"slim/psr7": "^1.8",

config/prod.php

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@
1313
use App\Core\ServiceFactory\Command\CommandsFactory;
1414
use App\Core\ServiceFactory\DecodeEncode\TypeDecodersFactory;
1515
use App\Core\ServiceFactory\DecodeEncode\TypeEncodersFactory;
16-
use App\Core\ServiceFactory\Framework\ExceptionMiddlewareFactory;
17-
use App\Core\ServiceFactory\Framework\MiddlewaresFactory;
18-
use App\Core\ServiceFactory\Framework\RouteMatcherFactory;
19-
use App\Core\ServiceFactory\Framework\RouteMatcherMiddlewareFactory;
20-
use App\Core\ServiceFactory\Framework\RoutesByNameFactory;
21-
use App\Core\ServiceFactory\Framework\RoutesDelegator;
22-
use App\Core\ServiceFactory\Framework\RoutesFactory;
23-
use App\Core\ServiceFactory\Framework\UrlGeneratorFactory;
16+
use App\Core\ServiceFactory\Framework\ErrorHandlerFactory;
17+
use App\Core\ServiceFactory\Framework\FastRouteRouterFactory;
18+
use App\Core\ServiceFactory\Framework\NotFoundHandlerFactory;
19+
use App\Core\ServiceFactory\Framework\ServerRequestErrorResponseGeneratorFactory;
20+
use App\Core\ServiceFactory\Framework\ServerRequestFactory;
2421
use App\Core\ServiceFactory\Http\ResponseFactoryFactory;
2522
use App\Core\ServiceFactory\Http\StreamFactoryFactory;
2623
use App\Core\ServiceFactory\Logger\LoggerFactory;
@@ -36,7 +33,6 @@
3633
use App\Pet\Orm\VaccinationMapping;
3734
use App\Pet\Parsing\PetParsing;
3835
use App\Pet\Repository\PetRepository;
39-
use App\Pet\ServiceFactory\Framework\PetRoutesDelegator;
4036
use App\Pet\ServiceFactory\Parsing\PetParsingFactory;
4137
use App\Pet\ServiceFactory\Repository\PetRepositoryFactory;
4238
use App\Pet\ServiceFactory\RequestHandler\Api\Crud\PetCreateRequestHandlerFactory;
@@ -52,12 +48,6 @@
5248
use Chubbyphp\DecodeEncode\Encoder\TypeEncoderInterface;
5349
use Chubbyphp\DecodeEncode\ServiceFactory\DecoderFactory;
5450
use Chubbyphp\DecodeEncode\ServiceFactory\EncoderFactory;
55-
use Chubbyphp\Framework\Middleware\ExceptionMiddleware;
56-
use Chubbyphp\Framework\Middleware\RouteMatcherMiddleware;
57-
use Chubbyphp\Framework\Router\RouteInterface;
58-
use Chubbyphp\Framework\Router\RouteMatcherInterface;
59-
use Chubbyphp\Framework\Router\RoutesByNameInterface;
60-
use Chubbyphp\Framework\Router\UrlGeneratorInterface;
6151
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\Common\Cache\ApcuAdapterFactory;
6252
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\DBAL\ConnectionFactory;
6353
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\DBAL\Tools\Console\ContainerConnectionProviderFactory;
@@ -80,11 +70,32 @@
8070
use Doctrine\ORM\EntityManagerInterface;
8171
use Doctrine\ORM\Tools\Console\EntityManagerProvider;
8272
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
73+
use Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
74+
use Laminas\HttpHandlerRunner\RequestHandlerRunner;
75+
use Laminas\Stratigility\Middleware\ErrorHandler;
76+
use Mezzio\Container\ApplicationPipelineFactory;
77+
use Mezzio\Container\EmitterFactory;
78+
use Mezzio\Container\MiddlewareContainerFactory;
79+
use Mezzio\Container\MiddlewareFactoryFactory;
80+
use Mezzio\Container\RequestHandlerRunnerFactory;
81+
use Mezzio\Handler\NotFoundHandler;
82+
use Mezzio\MiddlewareContainer;
83+
use Mezzio\MiddlewareFactory;
84+
use Mezzio\Response\ServerRequestErrorResponseGenerator;
85+
use Mezzio\Router\Middleware\DispatchMiddleware;
86+
use Mezzio\Router\Middleware\DispatchMiddlewareFactory;
87+
use Mezzio\Router\Middleware\MethodNotAllowedMiddleware;
88+
use Mezzio\Router\Middleware\MethodNotAllowedMiddlewareFactory;
89+
use Mezzio\Router\Middleware\RouteMiddleware;
90+
use Mezzio\Router\Middleware\RouteMiddlewareFactory;
91+
use Mezzio\Router\RouteCollector;
92+
use Mezzio\Router\RouteCollectorFactory;
93+
use Mezzio\Router\RouterInterface;
8394
use Monolog\Level;
8495
use Psr\Cache\CacheItemPoolInterface;
8596
use Psr\Http\Message\ResponseFactoryInterface;
97+
use Psr\Http\Message\ServerRequestInterface;
8698
use Psr\Http\Message\StreamFactoryInterface;
87-
use Psr\Http\Server\MiddlewareInterface;
8899
use Psr\Log\LoggerInterface;
89100
use Symfony\Component\Console\Command\Command;
90101

@@ -109,26 +120,32 @@
109120
EntityManager::class => EntityManagerInterface::class,
110121
],
111122
'factories' => [
123+
'Mezzio\ApplicationPipeline' => ApplicationPipelineFactory::class,
112124
AcceptMiddleware::class => AcceptMiddlewareFactory::class,
113-
AcceptNegotiatorInterface::class => AcceptNegotiatorFactory::class,
114125
AcceptNegotiatorInterface::class.'supportedMediaTypes[]' => AcceptNegotiatorSupportedMediaTypesFactory::class,
126+
AcceptNegotiatorInterface::class => AcceptNegotiatorFactory::class,
115127
ApiExceptionMiddleware::class => ApiExceptionMiddlewareFactory::class,
116128
CacheItemPoolInterface::class => ApcuAdapterFactory::class,
117129
Command::class.'[]' => CommandsFactory::class,
118130
Connection::class => ConnectionFactory::class,
119131
ConnectionProvider::class => ContainerConnectionProviderFactory::class,
120132
ContentTypeMiddleware::class => ContentTypeMiddlewareFactory::class,
121-
ContentTypeNegotiatorInterface::class => ContentTypeNegotiatorFactory::class,
122133
ContentTypeNegotiatorInterface::class.'supportedMediaTypes[]' => ContentTypeNegotiatorSupportedMediaTypesFactory::class,
134+
ContentTypeNegotiatorInterface::class => ContentTypeNegotiatorFactory::class,
123135
CorsMiddleware::class => CorsMiddlewareFactory::class,
124136
DecoderInterface::class => DecoderFactory::class,
137+
DispatchMiddleware::class => DispatchMiddlewareFactory::class,
138+
EmitterInterface::class => EmitterFactory::class,
125139
EncoderInterface::class => EncoderFactory::class,
126140
EntityManagerInterface::class => EntityManagerFactory::class,
127141
EntityManagerProvider::class => ContainerEntityManagerProviderFactory::class,
128-
ExceptionMiddleware::class => ExceptionMiddlewareFactory::class,
142+
ErrorHandler::class => ErrorHandlerFactory::class,
129143
LoggerInterface::class => LoggerFactory::class,
130144
MappingDriver::class => ClassMapDriverFactory::class,
131-
MiddlewareInterface::class.'[]' => MiddlewaresFactory::class,
145+
MethodNotAllowedMiddleware::class => MethodNotAllowedMiddlewareFactory::class,
146+
MiddlewareContainer::class => MiddlewareContainerFactory::class,
147+
MiddlewareFactory::class => MiddlewareFactoryFactory::class,
148+
NotFoundHandler::class => NotFoundHandlerFactory::class,
132149
OpenapiRequestHandler::class => OpenapiRequestHandlerFactory::class,
133150
ParserInterface::class => ParserFactory::class,
134151
Pet::class.CreateRequestHandler::class => PetCreateRequestHandlerFactory::class,
@@ -139,21 +156,16 @@
139156
PetParsing::class => PetParsingFactory::class,
140157
PetRepository::class => PetRepositoryFactory::class,
141158
PingRequestHandler::class => PingRequestHandlerFactory::class,
159+
RequestHandlerRunner::class => RequestHandlerRunnerFactory::class,
142160
ResponseFactoryInterface::class => ResponseFactoryFactory::class,
143-
RouteInterface::class.'[]' => RoutesFactory::class,
144-
RouteMatcherInterface::class => RouteMatcherFactory::class,
145-
RouteMatcherMiddleware::class => RouteMatcherMiddlewareFactory::class,
146-
RoutesByNameInterface::class => RoutesByNameFactory::class,
161+
RouteCollector::class => RouteCollectorFactory::class,
162+
RouteMiddleware::class => RouteMiddlewareFactory::class,
163+
RouterInterface::class => FastRouteRouterFactory::class,
164+
ServerRequestErrorResponseGenerator::class => ServerRequestErrorResponseGeneratorFactory::class,
165+
ServerRequestInterface::class => ServerRequestFactory::class,
147166
StreamFactoryInterface::class => StreamFactoryFactory::class,
148167
TypeDecoderInterface::class.'[]' => TypeDecodersFactory::class,
149168
TypeEncoderInterface::class.'[]' => TypeEncodersFactory::class,
150-
UrlGeneratorInterface::class => UrlGeneratorFactory::class,
151-
],
152-
'delegators' => [
153-
RouteInterface::class.'[]' => [
154-
PetRoutesDelegator::class,
155-
RoutesDelegator::class,
156-
],
157169
],
158170
],
159171
'directories' => [

infection.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"json": "build/phpinfection/infection.json",
1212
"summary": "build/phpinfection/summary.log",
1313
"stryker": {
14-
"report": "chubbyphp"
14+
"report": "mezzio"
1515
}
1616
},
1717
"mutators": {

public/index.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use Slim\Psr7\Factory\ServerRequestFactory;
6-
7-
/** @var Chubbyphp\Framework\Application $web */
5+
/** @var Mezzio\Application $web */
86
$web = (require __DIR__ . '/../src/web.php')(getenv('APP_ENV'));
9-
$web->emit($web->handle((new ServerRequestFactory())->createFromGlobals()));
7+
$web->run();

src/Core/ServiceFactory/Framework/ExceptionMiddlewareFactory.php renamed to src/Core/ServiceFactory/Framework/ErrorHandlerFactory.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,24 @@
44

55
namespace App\Core\ServiceFactory\Framework;
66

7-
use Chubbyphp\Framework\Middleware\ExceptionMiddleware;
7+
use Laminas\Stratigility\Middleware\ErrorHandler;
8+
use Mezzio\Middleware\ErrorResponseGenerator;
89
use Psr\Container\ContainerInterface;
910
use Psr\Http\Message\ResponseFactoryInterface;
10-
use Psr\Log\LoggerInterface;
1111

12-
final class ExceptionMiddlewareFactory
12+
final class ErrorHandlerFactory
1313
{
14-
public function __invoke(ContainerInterface $container): ExceptionMiddleware
14+
public function __invoke(ContainerInterface $container): ErrorHandler
1515
{
1616
/** @var ResponseFactoryInterface $responseFactory */
1717
$responseFactory = $container->get(ResponseFactoryInterface::class);
1818

1919
/** @var array{debug: bool} $config */
2020
$config = $container->get('config');
2121

22-
/** @var LoggerInterface $logger */
23-
$logger = $container->get(LoggerInterface::class);
24-
25-
return new ExceptionMiddleware(
22+
return new ErrorHandler(
2623
$responseFactory,
27-
$config['debug'],
28-
$logger
24+
new ErrorResponseGenerator($config['debug'])
2925
);
3026
}
3127
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\ServiceFactory\Framework;
6+
7+
use Mezzio\Router\FastRouteRouter;
8+
use Psr\Container\ContainerInterface;
9+
10+
final class FastRouteRouterFactory
11+
{
12+
public function __invoke(ContainerInterface $container): FastRouteRouter
13+
{
14+
/** @var array{fastroute: array{cache: null|string}} */
15+
$config = $container->get('config');
16+
17+
$fastrouteConfig = [];
18+
19+
if (null !== $config['fastroute']['cache']) {
20+
$fastrouteConfig[FastRouteRouter::CONFIG_CACHE_ENABLED] = true;
21+
$fastrouteConfig[FastRouteRouter::CONFIG_CACHE_FILE] = $config['fastroute']['cache'];
22+
}
23+
24+
return new FastRouteRouter(null, null, $fastrouteConfig);
25+
}
26+
}

src/Core/ServiceFactory/Framework/MiddlewaresFactory.php

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\ServiceFactory\Framework;
6+
7+
use Mezzio\Handler\NotFoundHandler;
8+
use Psr\Container\ContainerInterface;
9+
use Psr\Http\Message\ResponseFactoryInterface;
10+
11+
final class NotFoundHandlerFactory
12+
{
13+
public function __invoke(ContainerInterface $container): NotFoundHandler
14+
{
15+
/** @var ResponseFactoryInterface $responseFactory */
16+
$responseFactory = $container->get(ResponseFactoryInterface::class);
17+
18+
return new NotFoundHandler($responseFactory);
19+
}
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\ServiceFactory\Framework;
6+
7+
use Psr\Container\ContainerInterface;
8+
use Psr\Http\Message\ResponseFactoryInterface;
9+
10+
final class ResponseFactory
11+
{
12+
public function __invoke(ContainerInterface $container): \Closure
13+
{
14+
return static function () use ($container) {
15+
/** @var ResponseFactoryInterface $responseFactory */
16+
$responseFactory = $container->get(ResponseFactoryInterface::class);
17+
18+
return $responseFactory->createResponse();
19+
};
20+
}
21+
}

0 commit comments

Comments
 (0)