phpfox / container
A simple DI container for the PHPFox framework
Fund package maintenance!
JustSteveKing
Installs: 8 050
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^8.0
- psr/container: ^1.1 || ^2.0
Requires (Dev)
- pestphp/pest: ^1.5
- vimeo/psalm: ^4.7
Provides
README
This is the repository for the DI Container used in the PHP-Fox framework.
Installation
You should not need to install this package when using the PHP-Fox framework, however if you wish to use this outside of the framework please use:
composer require phpfox/container
Usage
To use the container, all you need to do is:
$container = Container::getInstance(); $container->bind( abstract: Abstract::class, concrete: Concrete::class, shared: false, // defaults to false - true turns this into a singleton. ); /** * @var bool */ $exists = $container->has( id: Abstract::class, ); /** * @var Concrete */ $concrete = $container->make( abstract: Abstract::class, );
Container implementation inspired by example repo from Jess Archer, which provides a great and simple base.