getcwd()
fera ce que vous avez besoin. Vous pouvez exécuter app/console à partir de n'importe quel répertoire, et PHP va savoir lequel il est.
J'ai utilisé l'exemple suivant pour vérifier cela.
<?php
namespace Acme\DemoBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class DemoCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('demo:cwd')
->setDescription('Get Current Working Directory')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(getcwd());
}
}
Peut-être utiliser 'getcwd()'? – mkjasinski
@mkjasinski Que se passe-t-il si je lance la commande avec 'exec' depuis le contrôleur Symfony (environnement web)? – gremo