Skip to content

More performance, extensible and centralized DI-Continer

Latest
Compare
Choose a tag to compare
@pretzlaw pretzlaw released this 03 Jan 01:46
· 13 commits to release/0.8 since this release

WordPress Dependency Injection now offers a Factory for some Provider and (more important) a centralized container that can be reused among all plugins/themes:

<?php

\RmpUp\WpDi\WpDi::load( require 'services.php' );

$container = \RmpUp\WpDi\WpDi::pimple();

Reusing an already existing container and the existing provider (by using the ::load()-Method) greatly enhances the performance.

Other changes:

  • Features
    • Preload core files using "preload.php" (esp. for the PHP 7.4 feature) to increase performance.
    • Loader: The static WpDi::loader() helps to fasten up loading
    • Introduced a factory for easier provider creation
  • Bugfixes
    • An argument-string can now have a leading "@" char without the service needed to exist.
  • Backward incompatibility / deprecations
    • Get rid of ServiceProviderInterface to switch to a more tree-like provider/parser.
    • Drop Provider::register methods to no decouple PSR11 and pimple for more flexibility.
    • Template references now must have a percentage sign "%" as pre- and suffix
    • Removed all sanitizer which need some rework towards a layer that can be cached.
    • Replaced LazyService with LazyPimple to decouple from PSR11 for more flexibility.
    • Dropped various internal deprecated structures.
  • Quality assuarance
    • Performance profiling using xhprof
    • Fixed some IDE warnings like typo and inspections.