Concept
Package pckg/concept implements context (DI container) and resolvers.
Installation
Require Composer package.
$ composer require pckg/contextUsage
A global context holds singletones and registers resolvers which automatically resolve an instance of the requested class or interface.
There are 4 main resolvers used:
ContextResolver- resolves instances registered in theContextFrameworkResolver- resolves singletone services such asRouter,Request,Configand similarFormResolver- resolves form, initializes fields, fills defaults from the request body, performs validationReflectResolver- auto-creates requested interfaces or classes
When the app is accessed/run via entrypoint (index.php, dev.php, console.php or bootstrap.php in tests), we first require Composer's autoload.php file.
On second step, we create a new Context by first registering all resolvers and creating a new Context.
The third step is where the global event Dispatcher is created.
Then we create an Environment and Application, initialize the app, run the app and reach the end of the request lifecycle.
require autoload.php -> create Context -> bind Dispatcher -> create Environment -> create Application -> init app -> run appLast updated
Was this helpful?