How to create an Aura DI container?

98 Views Asked by At

I installed a composer, downloaded the Aura, created an index.pxp and wrote in it:

require('vendor/autoload.php');

use Aura\Di\ContainerBuilder;
$builder = new ContainerBuilder();
$di = $builder->newInstance();

$object = $di->newInstance('Vendor\Package\ClassName');

But phpStorm says:Undefined namespase DI

And i have error: Fatal error: Class 'Aura\Di\ContainerBuilder' not found in... on line 4

I do as follows: http://auraphp.com/packages/3.x/Di/getting-started.html#1-1-1

1

There are 1 best solutions below

0
Phil On BEST ANSWER

In order for the composer auto-loader to pick up \Aura\Di, the dependency needs to be managed by composer.

You can easily do this by executing

composer require aura/di

which will add the dependency to your composer.json file and register with the auto-loader.


If you have manually downloaded and installed aura/di, you can revert that.