T
T
TANK_IST2017-08-01 22:28:22
symfony
TANK_IST, 2017-08-01 22:28:22

How to initialize symfony dependency injection without using symfony?

I use symfony components in development.
I want to be able to call components like in symfony ($this->container->get('router'))
We need router, doctrine, session and so on.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Skobkin, 2017-08-08
@TANK_IST

It seems you have an error here:

$container
        ->register('doctrine.setup')
        ->addArgument(array(
            array(APP_DIR."/Model"),
            APP_DEV,
            null,
            null,
            false
        ))
        ->setFactory(array(Doctrine\ORM\Tools\Setup::class, 'createAnnotationMetadataConfiguration'));

Specifically, in a challenge ->addArgument(). See here . You need to pass each argument in separate calls. That is, instead of:
By moving your code to manual initialization, you do:
instead of:
That is, you pass all arguments as an array to the first argument. From here you have "Array to string conversion", and everything else. If you used a debugger, you would find it yourself.

G
GTRxShock, 2017-08-01
@GTRxShock

svn.symfony-project.com/components/dependency_inje ...
svn.symfony-project.com/components/dependency_inje ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question