在phpunit.xml中更改php.ini配置选项 [英] Changing php.ini configuration option in phpunit.xml

查看:97
本文介绍了在phpunit.xml中更改php.ini配置选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行PHPUnit测试,并且需要将short_open_tag php.ini设置更改为On.

I'm trying to run PHPUnit tests, and need to change the short_open_tag php.ini setting to On.

遵循 PHPUnit手册,这在我的phpunit.xml配置文件中:

Following the PHPUnit Manual, I have this in my phpunit.xml config file:

<phpunit>
    <php>
        <ini name='short_open_tag' value='On' />
    </php>

    ...
</phpunit>

但是,这不会覆盖正在使用的php.ini文件中的设置(设置为关闭").如果我进入该文件并手动将值更改为开",则它可以工作.但是,我只想保留该设置,而仅在PHPUnit测试中更改它.

But this doesn't override the setting in the php.ini file being used (which is set to 'Off'). If I go into that file and manually change the value to 'On', it works. But, I'd like to leave that setting alone and only change it for the PHPUnit tests.

我的最佳猜测:我的应用程序(和phpunit.xml文件)在VM上,但似乎PHPUnit引用了本地计算机上的php.ini文件,因此从phpunit.xml设置配置选项会影响VM中而不是本地计算机上的php.ini文件.但我不确定如何更改.

My best guess: My application (and phpunit.xml file) is on a VM, but it appears that PHPUnit is referencing the php.ini file on my local machine, so setting the configuration option from the phpunit.xml is affecting the php.ini file in the VM and not on my local machine. But I'm not sure how to change that.

我哪里出错了?

推荐答案

您无法在运行时更改short_open_tag设置(这是phpunit.xml中的配置正在执行的操作).

You cannot change the short_open_tag setting at runtime (which is what the configuration in phpunit.xml is doing).

如果您查看文档,则short_open_tag位于PHP_INI_PERDIR组.

If you look at the documentation, short_open_tag is in the PHP_INI_PERDIR group.

这意味着只能在php.ini中进行设置, .htaccesshttpd.conf.user.ini.

It means it can only be set in php.ini, .htaccess, httpd.conf or .user.ini.

这篇关于在phpunit.xml中更改php.ini配置选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆