Skip to content

Commit bbb7bdf

Browse files
committed
slim-postgres
1 parent 6003b1d commit bbb7bdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+538
-740
lines changed

.php-cs-fixer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
/** @var array $config */
1414
$config = require __DIR__ . '/vendor/chubbyphp/chubbyphp-dev-helper/phpcs.php';
1515

16+
$config['rules']['static_lambda'] = false;
17+
1618
return (new PhpCsFixer\Config)
1719
->setUnsupportedPhpVersionAllowed(true)
1820
->setIndent($config['indent'])

README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
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=slim)](https://github.com/chubbyphp/petstore/actions/workflows/ci.yml)
4+
[![Coverage Status](https://coveralls.io/repos/github/chubbyphp/petstore/badge.svg?branch=slim)](https://coveralls.io/github/chubbyphp/petstore?branch=slim)
5+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchubbyphp%2Fpetstore%slim)](https://dashboard.stryker-mutator.io/reports/github.com/chubbyphp/petstore/slim)
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 [slim][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
26-
* [monolog/monolog][14]: ^3.10
27-
* [ramsey/uuid][15]: ^4.9.2
28-
* [slim/psr7][16]: ^1.8
29-
* [symfony/console][17]: ^7.4.3|^8.0.3
30-
* [symfony/var-exporter][18]: ^7.4.0|^8.0.0
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.1
20+
* [chubbyphp/chubbyphp-laminas-config-factory][8]: ^1.5.1
21+
* [chubbyphp/chubbyphp-negotiation][9]: ^2.3.1
22+
* [chubbyphp/chubbyphp-parsing][10]: ^2.1.2
23+
* [doctrine/orm][11]: ^3.6.1
24+
* [monolog/monolog][12]: ^3.10
25+
* [ramsey/uuid][13]: ^4.9.2
26+
* [slim/psr7][14]: ^1.8
27+
* [slim/slim][15]: ^4.15.1
28+
* [symfony/console][16]: ^7.4.3|^8.0.3
29+
* [symfony/var-exporter][17]: ^7.4.0|^8.0.0
3130

3231
## Environment
3332

@@ -203,24 +202,24 @@ curl -XPUT 'https://admin:98T722Eqw99oqFCSJCnB@localhost:9200/_plugins/_ism/poli
203202

204203
2026 Dominik Zogg
205204

206-
[1]: https://github.com/chubbyphp/chubbyphp-framework
205+
[1]: https://github.com/slimphp/slim
206+
207207
[2]: https://packagist.org/packages/chubbyphp/chubbyphp-clean-directories
208208
[3]: https://packagist.org/packages/chubbyphp/chubbyphp-cors
209209
[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
219-
[14]: https://packagist.org/packages/monolog/monolog
220-
[15]: https://packagist.org/packages/ramsey/uuid
221-
[16]: https://packagist.org/packages/slim/psr7
222-
[17]: https://packagist.org/packages/symfony/console
223-
[18]: https://packagist.org/packages/symfony/var-exporter
210+
[5]: https://packagist.org/packages/chubbyphp/chubbyphp/chubbyphp-http-exception
211+
[6]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config
212+
[7]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config-doctrine
213+
[8]: https://packagist.org/packages/chubbyphp/chubbyphp-laminas-config-factory
214+
[9]: https://packagist.org/packages/chubbyphp/chubbyphp-negotiation
215+
[10]: https://packagist.org/packages/chubbyphp/chubbyphp-parsing
216+
[11]: https://packagist.org/packages/doctrine/orm
217+
[12]: https://packagist.org/packages/monolog/monolog
218+
[13]: https://packagist.org/packages/ramsey/uuid
219+
[14]: https://packagist.org/packages/slim/psr7
220+
[15]: https://packagist.org/packages/slim/slim
221+
[16]: https://packagist.org/packages/symfony/console
222+
[17]: https://packagist.org/packages/symfony/var-exporter
224223

225224
[60]: src/Core/Collection
226225
[61]: src/Pet/Collection

composer.json

Lines changed: 3 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 slim framework.",
44
"keywords": [
55
"chubbyphp",
66
"framework",
7+
"slim",
78
"skeleton"
89
],
910
"license": "MIT",
@@ -18,8 +19,6 @@
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",
@@ -30,6 +29,7 @@
3029
"monolog/monolog": "^3.10",
3130
"ramsey/uuid": "^4.9.2",
3231
"slim/psr7": "^1.8",
32+
"slim/slim": "^4.15.1",
3333
"symfony/console": "^7.4.3|^8.0.3",
3434
"symfony/var-exporter": "^7.4.0|^8.0.0"
3535
},

config/prod.php

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare(strict_types=1);
44

55
use App\Core\Middleware\ApiExceptionMiddleware;
6+
use App\Core\Middleware\ConvertHttpExceptionMiddleware;
67
use App\Core\RequestHandler\Api\Crud\CreateRequestHandler;
78
use App\Core\RequestHandler\Api\Crud\DeleteRequestHandler;
89
use App\Core\RequestHandler\Api\Crud\ListRequestHandler;
@@ -13,18 +14,15 @@
1314
use App\Core\ServiceFactory\Command\CommandsFactory;
1415
use App\Core\ServiceFactory\DecodeEncode\TypeDecodersFactory;
1516
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;
17+
use App\Core\ServiceFactory\Framework\CallableResolverFactory;
18+
use App\Core\ServiceFactory\Framework\InvocationStrategyFactory;
19+
use App\Core\ServiceFactory\Framework\RouteCollectorFactory;
20+
use App\Core\ServiceFactory\Framework\RouteParserFactory;
2421
use App\Core\ServiceFactory\Http\ResponseFactoryFactory;
2522
use App\Core\ServiceFactory\Http\StreamFactoryFactory;
2623
use App\Core\ServiceFactory\Logger\LoggerFactory;
2724
use App\Core\ServiceFactory\Middleware\ApiExceptionMiddlewareFactory;
25+
use App\Core\ServiceFactory\Middleware\ConvertHttpExceptionMiddlewareFactory;
2826
use App\Core\ServiceFactory\Negotiation\AcceptNegotiatorSupportedMediaTypesFactory;
2927
use App\Core\ServiceFactory\Negotiation\ContentTypeNegotiatorSupportedMediaTypesFactory;
3028
use App\Core\ServiceFactory\Parsing\ParserFactory;
@@ -36,7 +34,6 @@
3634
use App\Pet\Orm\VaccinationMapping;
3735
use App\Pet\Parsing\PetParsing;
3836
use App\Pet\Repository\PetRepository;
39-
use App\Pet\ServiceFactory\Framework\PetRoutesDelegator;
4037
use App\Pet\ServiceFactory\Parsing\PetParsingFactory;
4138
use App\Pet\ServiceFactory\Repository\PetRepositoryFactory;
4239
use App\Pet\ServiceFactory\RequestHandler\Api\Crud\PetCreateRequestHandlerFactory;
@@ -52,12 +49,6 @@
5249
use Chubbyphp\DecodeEncode\Encoder\TypeEncoderInterface;
5350
use Chubbyphp\DecodeEncode\ServiceFactory\DecoderFactory;
5451
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;
6152
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\Common\Cache\ApcuAdapterFactory;
6253
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\DBAL\ConnectionFactory;
6354
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\DBAL\Tools\Console\ContainerConnectionProviderFactory;
@@ -84,8 +75,11 @@
8475
use Psr\Cache\CacheItemPoolInterface;
8576
use Psr\Http\Message\ResponseFactoryInterface;
8677
use Psr\Http\Message\StreamFactoryInterface;
87-
use Psr\Http\Server\MiddlewareInterface;
8878
use Psr\Log\LoggerInterface;
79+
use Slim\Interfaces\CallableResolverInterface;
80+
use Slim\Interfaces\InvocationStrategyInterface;
81+
use Slim\Interfaces\RouteCollectorInterface;
82+
use Slim\Interfaces\RouteParserInterface;
8983
use Symfony\Component\Console\Command\Command;
9084

9185
$rootDir = realpath(__DIR__.'/..');
@@ -110,25 +104,26 @@
110104
],
111105
'factories' => [
112106
AcceptMiddleware::class => AcceptMiddlewareFactory::class,
113-
AcceptNegotiatorInterface::class => AcceptNegotiatorFactory::class,
114107
AcceptNegotiatorInterface::class.'supportedMediaTypes[]' => AcceptNegotiatorSupportedMediaTypesFactory::class,
108+
AcceptNegotiatorInterface::class => AcceptNegotiatorFactory::class,
115109
ApiExceptionMiddleware::class => ApiExceptionMiddlewareFactory::class,
116110
CacheItemPoolInterface::class => ApcuAdapterFactory::class,
111+
CallableResolverInterface::class => CallableResolverFactory::class,
117112
Command::class.'[]' => CommandsFactory::class,
118113
Connection::class => ConnectionFactory::class,
119114
ConnectionProvider::class => ContainerConnectionProviderFactory::class,
120115
ContentTypeMiddleware::class => ContentTypeMiddlewareFactory::class,
121-
ContentTypeNegotiatorInterface::class => ContentTypeNegotiatorFactory::class,
122116
ContentTypeNegotiatorInterface::class.'supportedMediaTypes[]' => ContentTypeNegotiatorSupportedMediaTypesFactory::class,
117+
ContentTypeNegotiatorInterface::class => ContentTypeNegotiatorFactory::class,
118+
ConvertHttpExceptionMiddleware::class => ConvertHttpExceptionMiddlewareFactory::class,
123119
CorsMiddleware::class => CorsMiddlewareFactory::class,
124120
DecoderInterface::class => DecoderFactory::class,
125121
EncoderInterface::class => EncoderFactory::class,
126122
EntityManagerInterface::class => EntityManagerFactory::class,
127123
EntityManagerProvider::class => ContainerEntityManagerProviderFactory::class,
128-
ExceptionMiddleware::class => ExceptionMiddlewareFactory::class,
124+
InvocationStrategyInterface::class => InvocationStrategyFactory::class,
129125
LoggerInterface::class => LoggerFactory::class,
130126
MappingDriver::class => ClassMapDriverFactory::class,
131-
MiddlewareInterface::class.'[]' => MiddlewaresFactory::class,
132127
OpenapiRequestHandler::class => OpenapiRequestHandlerFactory::class,
133128
ParserInterface::class => ParserFactory::class,
134129
Pet::class.CreateRequestHandler::class => PetCreateRequestHandlerFactory::class,
@@ -140,20 +135,14 @@
140135
PetRepository::class => PetRepositoryFactory::class,
141136
PingRequestHandler::class => PingRequestHandlerFactory::class,
142137
ResponseFactoryInterface::class => ResponseFactoryFactory::class,
143-
RouteInterface::class.'[]' => RoutesFactory::class,
144-
RouteMatcherInterface::class => RouteMatcherFactory::class,
145-
RouteMatcherMiddleware::class => RouteMatcherMiddlewareFactory::class,
146-
RoutesByNameInterface::class => RoutesByNameFactory::class,
138+
RouteCollectorInterface::class => RouteCollectorFactory::class,
139+
RouteParserInterface::class => RouteParserFactory::class,
140+
StreamFactoryInterface::class => StreamFactoryFactory::class,
147141
StreamFactoryInterface::class => StreamFactoryFactory::class,
148142
TypeDecoderInterface::class.'[]' => TypeDecodersFactory::class,
143+
TypeDecoderInterface::class.'[]' => TypeDecodersFactory::class,
144+
TypeEncoderInterface::class.'[]' => TypeEncodersFactory::class,
149145
TypeEncoderInterface::class.'[]' => TypeEncodersFactory::class,
150-
UrlGeneratorInterface::class => UrlGeneratorFactory::class,
151-
],
152-
'delegators' => [
153-
RouteInterface::class.'[]' => [
154-
PetRoutesDelegator::class,
155-
RoutesDelegator::class,
156-
],
157146
],
158147
],
159148
'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": "slim"
1515
}
1616
},
1717
"mutators": {

public/index.php

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

55
use Slim\Psr7\Factory\ServerRequestFactory;
66

7-
/** @var Chubbyphp\Framework\Application $web */
7+
/** @var Slim\App $web */
88
$web = (require __DIR__ . '/../src/web.php')(getenv('APP_ENV'));
9-
$web->emit($web->handle((new ServerRequestFactory())->createFromGlobals()));
9+
$web->run((new ServerRequestFactory())->createFromGlobals());
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\Middleware;
6+
7+
use Chubbyphp\HttpException\HttpException as ChubbyphpHttpException;
8+
use Psr\Http\Message\ResponseInterface;
9+
use Psr\Http\Message\ServerRequestInterface;
10+
use Psr\Http\Server\MiddlewareInterface;
11+
use Psr\Http\Server\RequestHandlerInterface;
12+
use Slim\Exception\HttpException as SlimHttpException;
13+
14+
final class ConvertHttpExceptionMiddleware implements MiddlewareInterface
15+
{
16+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
17+
{
18+
try {
19+
return $handler->handle($request);
20+
} catch (ChubbyphpHttpException $chubbyphpHttpException) {
21+
throw new SlimHttpException(
22+
$request,
23+
$chubbyphpHttpException->getMessage(),
24+
$chubbyphpHttpException->getStatus(),
25+
$chubbyphpHttpException
26+
);
27+
}
28+
}
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\ServiceFactory\Framework;
6+
7+
use Psr\Container\ContainerInterface;
8+
use Slim\CallableResolver;
9+
use Slim\Interfaces\CallableResolverInterface;
10+
11+
final class CallableResolverFactory
12+
{
13+
public function __invoke(ContainerInterface $container): CallableResolverInterface
14+
{
15+
return new CallableResolver($container);
16+
}
17+
}

src/Core/ServiceFactory/Framework/ExceptionMiddlewareFactory.php

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\ServiceFactory\Framework;
6+
7+
use Slim\Handlers\Strategies\RequestHandler;
8+
use Slim\Interfaces\InvocationStrategyInterface;
9+
10+
final class InvocationStrategyFactory
11+
{
12+
public function __invoke(): InvocationStrategyInterface
13+
{
14+
return new RequestHandler(true);
15+
}
16+
}

0 commit comments

Comments
 (0)