Download the PHP package brandembassy/slim-nette-extension without Composer
On this page you can find all versions of the php package brandembassy/slim-nette-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package slim-nette-extension
Nette Extension for integration of SLIM for API
This extension brings the power of Slim for applications using Nette DI. It enables you to easily work with Slim middleware stack and develop your API easily.
This package now uses Slim Framework 4.x
The general idea has been discussed in this article. (Czech language)
Philosophy
Single Responsibility
The main idea is to delegate responsibilities of the code handling requests to separated middlewares. For example:
- authentication
- validation
- business logic
How middlewares in Slim work is described here.
Easy configuration
Empowered by Nette DI and it's neon configuration syntax this package provides powerful and easy way to define your API.
Usage
So let's start!
Extension
Now register new extension by adding this code into your config.neon:
First API endpoint
Now let's say you want to make a REST endpoint creating channels, [POST] /new-api/2.0/channels
You need to define in parameters.api section in config.neon.
Both services and middlewares must be registered services in DI Container.
You can also reference the named service by its name.
See tests/SlimApplicationFactoryTest.php and tests/config.neon for more examples.
Execution
Now you can simply get SlimApplicationFactory class from your DI Container (or better autowire it), create app and run it.
Migrating from Slim 3 to Slim 4
Version 4.x of this package uses Slim Framework 4 instead of Slim Framework 3. The migration should be mostly transparent for users as the package maintains backward compatibility where possible.
Key Changes
- Dependencies: Slim 4 uses PSR-7, PSR-15, and PSR-17 standards more strictly
- Container: Slim 4 no longer provides its own container, but the package provides a compatibility layer
- Middleware: The double-pass middleware style (
$request, $response, $next) is still supported - Routing: Routes are now registered on the App instance directly (handled internally by the package)
What You Need to Do
For most users, the upgrade should be seamless:
- Update your
composer.jsonto require the new version - Run
composer update brandembassy/slim-nette-extension - Clear your cache directories (
temp/,tests/temp/) - Test your application
Breaking Changes
ResponseandResponseInterfacewrappers have been removed — route handlers now receive a plain PSR-7ResponseInterfacedirectlyRequestInterface::getRoute()now returns?Route(nullable)RequestInterfacegained new methods:getInnerRequest(),getRoutingResults()- If you were directly accessing Slim internals (like
Slim\ContainerorSlim\Router), you'll need to update your code - Custom middleware that relied on Slim 3 specific features may need updates
$app->run()and$app->handle()now apply a Content-Type fix for empty responses
Backward Compatibility
The following are maintained for backward compatibility:
- Middleware signature remains the same (double-pass style
$request, $response, $next) - Route handler signature remains the same (
$request, $response) - Route and handler registration via NEON configuration is unchanged
- Container access via
$app->getContainer()works as before
For more details on Slim 4 changes, see the official Slim 4 upgrade guide.
All versions of slim-nette-extension with dependencies
ext-apcu Version *
adbario/php-dot-notation Version ^2.2 || ^3.0
nette/di Version ^3.0
nette/neon Version ^3.0
nette/utils Version >=3.2
psr/http-message Version ^1.0 || ^2.0
psr/http-factory Version ^1.0
psr/http-server-middleware Version ^1.0
psr/http-server-handler Version ^1.0
slim/slim Version ^4.14
slim/psr7 Version ^1.6