loicfrering / losolib

Collection of components for Zend Framework applications and integration of Symfony Components.
http://losohome.wordpress.com/
MIT License
48 stars 6 forks source link

using LosoLib from command line - possible? #9

Closed luebbert42 closed 12 years ago

luebbert42 commented 12 years ago

Hi,

is it possible to use LosoLib in command line scripts?

At the moment my script is a copy of index.php, ending with $application->bootstrap(); and then some domain specific code.

It does not work because the DI container is not loaded and I can't call run() from command line.

Any hint on this? :-)

loicfrering commented 12 years ago

Hi,

Sorry for the delay... The DI should be bootstrapped with Zend_Application if the application.ini loaded in your script contains bootstrap.container.type = "symfony". In fact you can see that when configuring Doctrine CLI, I'm bootstrapping losolib and Symfony's DIC as well.

Let me know if you need more help.

luebbert42 commented 12 years ago

stupid me!!!

I almost had it, just missed that I have to get the DI container and use it ;-)

$container = $application->getBootstrap()->getContainer(); $import = $container->get("ImportService");

So, thanx again (do you have a flattr button or something like this somehwere?) :-)