Como executar o comando do pacote no controlador de aplicativo no Symfony3?
INTRODUÇÃO
No meu projeto pessoal, estou usando:
Symfony v3.2.7PHP v7.1.1CravlerMaxMindGeoIpBundleComo chamar um comando de um controladorNa máquina de desenvolvimento do Windows 10 ProALVOEu gostaria de correrCravlerMaxMindGeoIpBundle's
comandophp bin/console cravler:maxmind:geoip-update
do controlador com sucesso.
No momento eu configureiCravlerMaxMindGeoIpBundle
pacote e comandophp bin/console cravler:maxmind:geoip-update
funciona bem na linha de comando.
Depois segui a documentação oficial (4º link na seção de introdução). Comando de chamada alterada, é claro. E ainda assim eu recebo um erro.
[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "cravler:maxmind" namespace.
PERGUNTA, QUESTÃOO que devo fazer para executar o comando sem erro?
CÓDIGOMinha ação no controlador
public function geoIpUpdateAction(Request $request)
{
$kernel = $this->get('kernel');
$application = new Application($kernel);
$application->setAutoExit(false);
$input = new ArrayInput(array(
'command' => 'cravler:maxmind:geoip-update'
));
// You can use NullOutput() if you don't need the output
$output = new BufferedOutput();
$application->run($input, $output);
// return the output, don't use if you used NullOutput()
$content = $output->fetch();
// return new Response(""), if you used NullOutput()
dump($content);
return $this->render('admin/geo_ip.html.twig');
}
Meu AppKernel com pacotes habilitados
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new Bmatzner\FoundationBundle\BmatznerFoundationBundle(),
new Knp\Bundle\TimeBundle\KnpTimeBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Cravler\MaxMindGeoIpBundle\CravlerMaxMindGeoIpBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function getRootDir()
{
return __DIR__;
}
public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}
public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
FINALMENTEo que estou perdendo?