Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shadowhand/injector-interop
Dependency injector configuration interoperability
https://github.com/shadowhand/injector-interop
Last synced: 11 days ago
JSON representation
Dependency injector configuration interoperability
- Host: GitHub
- URL: https://github.com/shadowhand/injector-interop
- Owner: shadowhand
- License: mit
- Created: 2015-12-19T22:07:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-20T18:45:44.000Z (about 9 years ago)
- Last Synced: 2024-12-25T05:57:39.058Z (17 days ago)
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Injector Configuration Interoperability
*injector-interop* tries to identify and standardize features used by *dependency injector configuration* to achieve
interoperability. It is an alternative to [definition-interop][definition-interop].[definition-interop]: https://github.com/container-interop/definition-interop
Through discussions and trials, we try to create a standard, made of common interfaces but also recommendations.
If PHP projects that provide injector implementations begin to adopt these common standards, then PHP applications
and projects that use injector configuration can depend on the common interfaces instead of specific implementations.
This facilitates a high-level of interoperability and flexibility that allows users to use *any* injector implementation
to configure packages.The work done in this project is not officially endorsed by the [PHP-FIG](http://www.php-fig.org/).
We adhere to the spirit and ideals of PHP-FIG, and hope this project will pave the way for one or more future PSRs.## An Example
With [PSR-7][psr-7] there are many implementations of HTTP message interfaces, including [Zend Diactoros][diactoros].
The following could be used to tell an application to use this implementation of PSR-7:[psr-7]: http://www.php-fig.org/psr/psr-7/
[diactoros]: https://github.com/zendframework/zend-diactoros```php
use Interop\Injector\InjectorInterface;
use Interop\Injector\ConfigurationInterface;class DiactorosConfiguration implements ConfigurationInterface
{
/**
* @inheritDoc
*/
public function apply(InjectorInterface $injector)
{
$injector->alias(
'Psr\Http\Message\ResponseInterface',
'Zend\Diactoros\Response'
);$injector->alias(
'Psr\Http\Message\RequestInterface',
'Zend\Diactoros\Request'
);$injector->alias(
'Psr\Http\Message\ServerRequestInterface',
'Zend\Diactoros\ServerRequest'
);$injector->delegate(
'Zend\Diactoros\ServerRequest',
'Zend\Diactoros\ServerRequestFactory::fromGlobals'
);
}
}
```