![](/img/trans.png)
[英]convert currency symbol to XML decimal entity reference within PHP 5.3.10
[英]Getting Symfony Doctrine Entity Manager within PHP Docker container / phpbrew for PHP 5.3.10
我正在尝试使用PHP 5.3.10在Docker下运行Symfony命令。 当我到达像
class Data{
public function prepareData(){
echo 'before getContainer';
$em = $this->getContainer()->get('doctrine.orm.entity_manager')->getConnection();
echo 'after getContainer';
}
}
它无声地失败。
用于设置容器的docker命令是
docker run --network="host" -t -i -p 80:80 -v /srv/www/live/:/srv/www/live/ -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock bylexus/apache-php53 /bin/bash
在Docker容器中时,我将安装mysql,然后可以登录并查看本地系统上存在的数据库。
我在Docker容器中运行的Symfony命令就像
php app/console mytask:preparedata
从
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
class PrepareDataCommand extends Command
{
protected function configure()
{
parent::configure();
$this->setName('mytask:preparedata');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getHelper('Data')->prepareData();
}
}
它执行prepareData
函数。 “ getContainer之后”永远不会回显,只是“ getContainer之前”。 日志中没有任何内容,Apache,MySQL或Symfony。
您是否有一个想法,例如如何调试它或如何像在Docker外部那样获取容器?
更新资料
我现在使用phpbrew测试了它。 它适用于PHP版本5.6.30,但不适用于所需的PHP版本5.3.10(在与上述相同的$em = $this->getContainer
行处停止)。 奇怪的是,它在phpbrew的PHP 7.0.3上也不起作用。 就PHP版本而言,这可能是与Symfony或教义相关的问题吗?
我尝试了其他一些Symfony CLI命令,并注意到有时通过Composer安装的Doctrine供应商存储库中会出现致命错误。 经检查后,便是使用PHP 5.4语法(方括号)初始化数组的地方。 因此,这当然在5.3容器中不起作用。 因此,我将doctrine/cache
, doctrine/common
和doctrine/orm
降级了,这些命令现在可以运行了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.