ronanchilvers / container-bridge-slim
Convenience bridge for using ronanchilvers/container with slim3
Installs: 1 595
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- ronanchilvers/container: ^2.0
- slim/slim: ^3.9
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-25 22:59:24 UTC
README
A bridge for using ronanchilvers/container with Slim3. This package allows you to replace the default slim3 container (Pimple) with ronanchilvers/container.
Installation
The easiest way to install is via composer:
composer install ronanchilvers/container-bridge-slim
Usage
To replace the default slim container with ronanchilvers/container all you need to do is pass an instance of the container into the constructor of the slim app object. Here's an example:
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Ronanchilvers\Container\Slim\Container; use Slim\App; // Initialise a new container instance $container = new Container(); // Pass the container instance into the app object's constructor $app = new App($container); $app->get('/', function (ServerRequestInterface $request, ResponseInterface $response) { return $response->write('hallo'); }); $app->run();
Controlling Slim settings is similar to the usual Slim mechanism:
use Ronanchilvers\Container\Slim\Container; use Slim\App; $container = new Container([ 'settings' => [ 'displayErrorDetails' => true, ] ]); // Create the App object $app = new App($container);
Testing
This is quite simple a simple bridge and has 100% test coverage. You can run the tests by doing:
./vendor/bin/phpunit
The default phpunit.xml.dist file creates coverage information in a build/coverage subdirectory.
Contributing
If anyone has any patches they want to contribute I'd be more than happy to review them. Please raise a PR. You should:
- Follow PSR2
- Maintain 100% test coverage or give the reasons why you aren't
- Follow a one feature per pull request rule
License
This software is licensed under the MIT license. Please see the License File for more information.