Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akrabat/rka-slim-zfsm-container
Integration of Zend\ServiceManager into Slim 3
https://github.com/akrabat/rka-slim-zfsm-container
Last synced: 2 months ago
JSON representation
Integration of Zend\ServiceManager into Slim 3
- Host: GitHub
- URL: https://github.com/akrabat/rka-slim-zfsm-container
- Owner: akrabat
- License: bsd-3-clause
- Created: 2015-07-03T13:45:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-06T21:14:57.000Z (almost 9 years ago)
- Last Synced: 2024-11-01T08:42:18.557Z (2 months ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 9
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Use Zend\ServiceManager with Slim 3
This component enables you to replace the default Pimple container in Slim 3
with Zend\ServiceManager.## Usage
* `composer require akrabat/rka-slim-zfsm-container`
* update `index.php`:```php
$settings = [
'settings' => [
// user settings go here
],
'factories' => [
// new SM factories go here
],
// you can use any other SM key here too.
];
$container = new RKA\ZsmSlimContainer\Container($settings);
$app = new \Slim\App($container);
```There is also an [example application][1].
### Overriding Slim's defaults
To override the default Slim handlers (e.g. errorHandler, notFound, etc), you
can add them to the relevant section of `$settings` before instantiating the
container:```php
$settings = [
'factories' => [
'errorHandler' => function ($container) {
// do your own thing here
},
],
];
$container = new RKA\ZsmSlimContainer\Container($settings);
$app = new \Slim\App($container);
```Alternatively you can also override afterwards if you want to:
```php
$container->setAllowOverride(true);
$container['errorHandler'] = function($container) {
// set-up error handler
};
```[1]: https://github.com/akrabat/rka-slim-zfsm-container/blob/master/example-app/index.php