Reload php.ini without webserver - php

i have installed php on windows just for having opportunity running php commands.
One of those commands required from me enabling few extensions (mbstring, openssl). I have enabled them in php.ini, but still it cant see it because php is not reloaded. I dont have any webservers on windows (no IIS, Apache, Nginx). How can i just reload php and php.ini without any webservers?
Thanks!

Use php.exe --ini to display what configuration files are being used and edit the correct php.ini file.

Related

PHP CLI on Win10 no longer loading local ini file after upgrade to 7.4

I used to run PHP 5.6 on Win 10 in CLI mode. I had different php.ini files in different directories and PHP would always pick up the one in the current directory if one was there.
Now, after upgrading to PHP 7.4, PHP always loads the php.ini from where php.exe is installed.
I know that I can specify a different php.ini with the -c command line directive, but that's not convenient. Is there a way to restore the 5.6 behavior?
Additional info:
I'm seeing the same behavior change on the LINUX web server: local php.ini files that used to be loaded now get ignored. I was able to mostly solve it there by renaming them to .user.ini

Composer can't find ext-mbstring even though it is installed

When I attempt to install Laravel 5 I get a dependency error. I'm using Uniform Server on Windows 7. I have enabled php_mbstring.dll and I checked it's loading properly. (I think)
Here is the console output (Composer):
Here are the extensions in my php.ini
Here are the phpinfo() mbstring details:
I don't know where to go from here.
Any idea?
Pay attention that, both in Windows and Linux, PHP can run with multiples php.ini configuration files.
In general, when you find this kind of issue, you have to double check that the configuration file loaded is the same that you are editing or you need to find the right path and add the extension also to the right php.ini configuration file.
While running a script through a web server, you can find the configuration file using the function
phpinfo();
and checking the line "Loaded Configuration File" (or just look for php.ini)
For what concern the CLI you can run in CMD
php --ini
and check the first lines in order to find the Loaded Configuration File value.

php can not load extension

I have...
1.compiled and made ssh2.so.
2.placed the PHP extension (ssh2.so) in the "extension_dir"
3.been editing the correct php.ini file (extension=ssh2.so), the file "Loaded
Configuration File" entry listed in the phpinfo() output.
4.restarted apache server.
but, "php -m" prints no ssh2 module.
any idea?
For php -m to show the ssh2 module, you have to edit the CLI php.ini for that.
There are generally TWO php.ini, one for Apache module and the other for the CLI version of PHP.
In Ubuntu, you will edit /etc/php5/cli/php.ini, but YMMV
Oh, and the syntax is very much the same, so a copy-paste should do the job.
Hope this helps !
It is not php -m that you want to do but rather to create a php file in your web site containing:
<?php
phpinfo();
?>
Accessing this via Apache will show you what modules are loaded. You may want to configure Apache to secure access to this.

Trouble changing `upload_max_filesize` on nginx

I've see a few other similar questions on here, but most of the answers are Apache specific (dealing with their .htaccess file) and I'm using nginx.
I'm having trouble making my change to the upload_max_filesize in php.ini stick. I'm using nginx, php5 and wordpress on Debian.
When I run phpinfo() I see the following output:
Loaded Configuration File /etc/php5/cgi/php.ini
I then go to the relevant .ini file, change a few values, and then restart nginx. When I fire up a phpinfo() plugin I got for wordpress, it reports the values as unchanged.
I'm at a loss because phpinfo() reports that it is loading config values from the file that I've changed, but it doesn't report the changes.
You might be using FAST CGI:
[webserver] <----> [fcgi daemon]
`- [php]
If you restart the webserver, PHP is not restarted, so still has the old ini values because it didn't reload the ini file.
Restarting the fcgi daemon solves that issue, PHP will be restarted, re-reading the ini.
Some fcgi daemons have a command that reloads the child processes more gracefully. Depends on what you use.
For me the problem was a syntax error in the custom php.ini file, which I found after checking the error logs.
This might help the ones that are using php -i from the terminal to check php.ini settings.
In my case, I increased the upload_max_filesize from 2M to 20 MB by editing /etc/php/7.3/apache2/php.ini and restarted the apache by apachectl restart command.
I used php -i command from the Debian terminal to see the changes are in effect but upload_max_filesize was still 2M.
Then I realized settings readings came from /etc/php/7.3/cli/php.ini because I was using php -i from the terminal instead of phpinfo() function in a web page.
$ sudo service php7.4-fpm restart
Resolved my problem. change the php version to the one you using.

php.ini reload in php-cli

I have php script that must be runned from console (php-cli). But configuration of php.ini for php-cli was incorrect. I fix it, but when I run script a had error with php config, because php.ini uses an old.
How I can reload php.ini for console without restart server?
The configuration is loaded fresh each time you invoke PHP from the CLI.

Categories