Voglio alcuni comandi del terminale per l'applicazione Symfony2. Ho esaminato lo example in the cookbook, ma non sono riuscito a scoprire come accedere alle mie impostazioni, al mio gestore di entità e alle mie entità qui. Nel costruttore, ottengo il contenitore (che mi dovrebbe produrre l'accesso alle impostazioni e alle entità) utilizzandoCome utilizzare i miei Entity Manager ed Entity Manager nel comando console di Symfony 2?
$this->container = $this->getContainer();
Ma questa chiamata genera un errore:
Fatal error: Call to a member function getKernel() on a non-object in /Users/fester/Sites/thinkblue/admintool/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php on line 38
In sostanza, in ContainerAwareCommand-> getContainer() la chiamata a
$this->getApplication()
restituisce NULL e non un oggetto come previsto. Immagino di aver lasciato un passo importante, ma quale? E come potrò finalmente usare le mie impostazioni ed entità?
sto avendo lo stesso errore quando (e tento di accedere 'getContainer() 'all'interno di' MyCommand-> execute() 'ma ottiene lo stesso errore fatale. il mio' CommandTest estende \ PHPUnit_Framework_Testcase' e lo eseguo tramite 'phpunit -c app src/CompanyName/MyBundle/Tests/Commands/MyCommandTest.php' Qualche idea su cosa può essere sbagliato? –