Download the PHP package gixx/worstpractice-dependency-injection without Composer
On this page you can find all versions of the php package gixx/worstpractice-dependency-injection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gixx/worstpractice-dependency-injection
More information about gixx/worstpractice-dependency-injection
Files in gixx/worstpractice-dependency-injection
Package worstpractice-dependency-injection
Short Description A simple dependency injection container
License MIT
Homepage http://www.worstpractice.dev
Informations about the package worstpractice-dependency-injection
The worstpractice.dev presents
DIY Dependency Injection
The complete source code for the series of articles DIY Dependency Injection Container part 1, 2 and 3.
Purpose
The only purpose is practicing:
- PHP 7.4, 8.0, 8.1 and 8.2 features
- keep coding standards
- write clean code
- write strict-typed code
- Unit testing
Although, I believe it works like any other DIC, I don't recommend to use it in production. Unfortunately the code quality checks on the Scrutinizer CI side don't yet support PHP 8.2.
Installation
To add this package to your project, just get it via composer:
Usage
To use it, you will need only a configuration as in the example:
This DIC will instantiate any class only when it is requested or being referenced by a requested class. It also supports adding instance into the DIC. It comes in handy when the script needs an instance based on some calculation.
Testing
The package contains a simple Docker setup to be able to run tests. For this you need only run the following:
The following tests will run:
- PHP lint
- PHP Mess Detector
- PHP Unit
- PHPStan (max level, no ignored Errors)
The following tests form the PHP 7.4 version are now ignored, since they don't yet have PHP 8.2 support:
- PHP-CS-Fixer
- PHP Code Sniffer