Skip to content

Commit

Permalink
Replace Dice with slince/di
Browse files Browse the repository at this point in the history
Dice is okay but the code is showing its age (very dynamic),
it is not very actively developed and lacks PSR-11 support.

Looking at other options on Packagist, skipping obviously abandoned
or associated with the facade-infested framework:

- https://github.com/nette/di
  😡 container generator
  😡 too featureful
- https://github.com/symfony/dependency-injection
  🙂 native PSR-11
  😡 promotes configuration
- https://github.com/PHP-DI/PHP-DI
  🙂 nice docs
  😡 also too featureful
- https://github.com/auraphp/Aura.Di
  😡 verbose API
- https://github.com/ray-di/Ray.Di
  🙂 nice docs
  😡 “enterprise” API
- https://github.com/slince/di
  🙂 native PSR-11
  🙂 nice API
  😡 few unneeded features (aliases, parameters, tags)
- https://github.com/thephpleague/container
  🙂 native PSR-11
  🙂 nice API
  🙂 nice docs
  😡 even more unneeded features (inflectors)

After reviewing all of the above, I selected Slince’s DI library.
There were some bugs but they were quickly addressed upstream.
  • Loading branch information
jtojnar committed Jun 15, 2023
1 parent 6630912 commit 31ef53d
Show file tree
Hide file tree
Showing 13 changed files with 413 additions and 304 deletions.
9 changes: 5 additions & 4 deletions cliupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

declare(strict_types=1);

use helpers\UpdateVisitor;
use Psr\Container\ContainerInterface;

chdir(__DIR__);
require __DIR__ . '/src/common.php';

use helpers\UpdateVisitor;

/** @var Dice\Dice $dice */
$loader = $dice->create(helpers\ContentLoader::class);
/** @var ContainerInterface $container */
$loader = $container->get(helpers\ContentLoader::class);
$updateVisitor = new class() implements UpdateVisitor {
public function started(int $count): void {
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"guzzlehttp/psr7": "^2.0",
"http-interop/response-sender": "^1.0",
"j0k3r/graby": "^2.0",
"level-2/dice": "^4.0",
"lordelph/icofileloader": "^2.0",
"mibe/feedwriter": "^1.0",
"monolog/monolog": "^2.0",
"php-http/guzzle7-adapter": "^1.0",
"psr/container": "^1.1",
"psr/simple-cache": "^1.0",
"simplepie/simplepie": "^1.8",
"slince/di": "^3.2",
"smottt/wideimage": "^1.1",
"symfony/cache": "^5.4",
"symfony/polyfill-php80": "^1.26",
Expand Down
180 changes: 129 additions & 51 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 31ef53d

Please sign in to comment.