Small dependency injection container for PHP
open sourceMITfree
Pimple is a small dependency injection container for PHP. It holds services, defined as anonymous functions and created lazily on first use, and parameters; services can be shared or factories, protected closures stay callables, and definitions can be extended or grouped in service providers. Pimple is closed for changes: its maintainers accept only compatibility with newer PHP versions and security fixes.
Problems it solves
- add a lightweight dependency injection container to a small PHP app
- wire up PHP services lazily without a full framework
- share one database connection object across a PHP application
Features
- services defined as anonymous functions and created lazily
- shared services and factory services
- parameters and protected closures
- extending existing service definitions
- service providers to group definitions
Limitations
- Closed for changes: no new features, only compatibility with newer PHP versions and security fixes.1
Alternatives
The same job
These do what Pimple does.
- PHP-DI The dependency injection container for humans
- laminas-servicemanager A factory-driven dependency injection container for PHP from the Laminas Project
