Petah
Petah

Reputation: 46060

Loading a .user.ini PHP conf file using the PHP 5.4 internal server?

How do you load a .user.ini PHP configuration file when using the built in web server?

My setup is like this:

site
│   include.php
│
├───bin
│       router.php
│       server.bat
│
└───public
        .user.ini
        index.php

The document root is public, and bin\router.php routes to public\index.php if the file does not exist.

I did a phpinfo(), to verify that the .user.ini was not being loaded. The setting I am trying to change is error_log.

Upvotes: 2

Views: 3324

Answers (2)

TerryE
TerryE

Reputation: 10888

Petah, I've just twigged what the issue is from your comment. The built-in webserver was only introduced in 5.4

This web server is designed for developmental purposes only, and should not be used in production.

It acts as a webserver listening on the specified socket. The .user.ini states that:

These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.

In other words you can't use .user.ini files with the built-in webserver or with Apache/mod_php, etc. You have to use a custom php.ini. The safest way to do this is to clone the default php.ini (or php_value/flag directives with Apache/mod_php) and then add the lines you want for development. Of course you could always just add an ini_set command in you script(s) startup as well.

Upvotes: 3

Petah
Petah

Reputation: 46060

While not an exact answer to my question, I found a solution to my problem.

In the server.bat file I was running the php server using

php -S 0.0.0.0:3000 -t public bin/router.php

By changing it to:

php -c public/.user.ini -S 0.0.0.0:3000 -t public bin/router.php

Achieved the same effect.

Upvotes: 1

Related Questions