1
如何從下面的類中的yml文件獲取參數,以便可以使用CLI打印它?訪問CLI類中的參數
錯誤:
mbp:symfony em$ app/console phing:report
PHP Fatal error: Call to undefined method Site\CommonBundle\Command\GreetCommand::getParameter() in symfony/src/Site/CommonBundle/Command/GreetCommand.php on line 25
的symfony/src目錄/網站/ CommonBundle /命令/ GreetCommand.php
namespace Site\CommonBundle\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 GreetCommand extends ContainerAwareCommand
{
public function __construct()
{
parent::__construct();
}
protected function configure()
{
$this->setName('phing:report');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$user = $this->getParameter('dummy_user');
$output->writeln($user['admin']['username']);
}
}
的symfony /應用/配置/ globals_dev.yml
#Site globals
parameters:
dummy_user:
admin:
username: admin
superadmin:
username: superadmin
就這麼簡單!謝謝。 – BentCoder 2014-10-01 14:44:22