-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Slim 5 Road Map
Daniel Opitz edited this page Jul 21, 2024
·
26 revisions
Status: Draft / Planning
Current working branch: https://github.com/odan/Slim/tree/5.x
Changelog: https://github.com/odan/Slim/blob/5.x/CHANGELOG.md
Slim 5 Issues: https://github.com/slimphp/Slim/issues?q=is%3Aissue+is%3Aopen+label%3A%22Slim+5%22
- Collect feedback from the Slim community to identify pain points and desired features.
- Identify how new PHP 8 features can be integrated to enhance Slim 5
- Bring back the simplicity. Simplify App instantiation. The AppFactory should not be needed anymore.
- Improve DI container integration. Make the DI container a first-class citizen. Require a PSR-11 package.
- Ensure that route attributes are always in the Request #3280
- Unify CallableResolver and AdvancedCallableResolver #3073
- Resolving middleware breaks if resolver throws unexpected exception type #3071
- Forward logger to own ErrorHandlingMiddleware #2943
- Provide interfaces for each integrated feature
- Add new EndpointRoutingMiddleware and the new EndpointMiddleware
- Optimize middleware execution pipeline: Provide FIFO middleware support
- Provide integrated base path middleware
- Provide CallbackStream.
- Provide a ShutdownHandler (using a new ShutdownHandlerInterface)
- Provide support for other routing packages (EndpointRoutingMiddleware)
- Provide support for custom error handlers using a new interface (ExceptionHandlerInterface)
- Provide support for custom Response emitter
- Require >= PHP 8.2
- PSR-7 and PSR-15 compliance: Require at least psr/http-message 2.0.
- PSR-11 compliance: Require at least psr/container 2.0.
- PSR-3 compliance: Require at least psr/log 3.0
- Update and expand the official documentation to cover new features and best practices.
- Provide updated tutorials and example applications to help developers get started with Slim 5.
- Add migration guide
- Move ErrorMiddleware from Slim 4 into a new package
- Require PHPUnit 11.
- Optimize tests. Avoid mocking where possible.
- Use Mockery for all new tests which require mocking. Drop prophecy?
- Release Candidate: Prepare and release the Slim 5 release candidate for final testing.
- Official Release: Launch Slim 5 with complete documentation and migration guides.
Installation:
composer require slim/slim:5.*
composer require slim/psr7
composer require php-di/php-di
File: public/index.php
<?php
use Slim\App;
use Slim\Middleware\EndpointMiddleware;
use Slim\Middleware\EndpointRoutingMiddleware;
use Slim\Middleware\ExceptionHandlerMiddleware;
require __DIR__ . '/../vendor/autoload.php';
// Create App without AppFactory
// This will create the DI container instance internally
$app = new App();
// Add middleware (LIFO by default)
// Add routing middleware
$app->add(EndpointMiddleware::class);
$app->add(EndpointRoutingMiddleware::class);
// Optional: Add Exception Middleware
$app->add(ExceptionHandlerMiddleware::class);
// Register Routes
$app->get('/', function ($request, $response, $args) {});
// Run the app
$app->run();
<?php
use DI\ContainerBuilder;
use Slim\App;
use Slim\Middleware\BasePathMiddleware;
use Slim\Middleware\BodyParsingMiddleware;
use Slim\Middleware\EndpointMiddleware;
use Slim\Middleware\EndpointRoutingMiddleware;
use Slim\Middleware\ExceptionHandlerMiddleware;
require __DIR__ . '/../vendor/autoload.php';
// Build DI container instance
$container = (new ContainerBuilder())
->addDefinitions(__DIR__ . '/../config/container.php')
->build();
// Create App with custom DI container
$app = new App($container);
// Add middleware (LIFO by default)
$app->add(EndpointMiddleware::class);
$app->add(EndpointRoutingMiddleware::class);
$app->add(BodyParsingMiddleware::class);
$app->add(BasePathMiddleware::class);
$app->add(ExceptionHandlerMiddleware::class);
// Register routes
$app->get('/', \App\Action\HomeAction::class);
// Run the app
$app->run();