Yeah this is what I thought...
I just found a way to create it from inside a Front Controller :
require_once _PS_ROOT_DIR_.'/app/AppKernel.php'; class IndexController extends IndexControllerCore{ public function initContent(){ global $kernel; dump($kernel); // null $kernel = new \AppKernel('prod', false); dump($kernel); // kernel with null container $kernel->boot(); dump($kernel->getContainer()); // Container OK, we can call $kernel->getContainer()->get('service') die(); } }
Thanks
Florian
Source: full article in https://blog.floriancourgey.com/2018/05/how-to-work-with-the-symfony-kernel-anywhere-in-prestashop-1-7/
PS : refacto to put on in /override/classes/controller/Controller :
protected $kernel; public function __construct(){ global $kernel; dump($kernel); // can return null if(!$kernel){ // if null, we boot it manually require_once _PS_ROOT_DIR_.'/app/AppKernel.php'; $kernel = new \AppKernel('prod', false); dump($kernel); // kernel without container $kernel->boot(); // kernel with container } dump($kernel->getContainer()); // yay ! $this->kernel = $kernel; }