Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

daglimioux's avatar

Changing PHP settings

Hi!

Is there a way in Laravel to access to php.ini settings or do you know a package to edit those settings and save them? If it can be made with pure PHP, I would also like to know it.

I'm building a page for my app to allow admins to edit those settings by their own risk. Any suggestion?

Thanks.

Best regards, D.

PS: I was thinking in something like a service provider using ini_set() function for each setting I would like that admins could modify and save those settings with my other custom settings for the app, but I don't know which approach is better/more secure. Btw, I don't know if this approach will take effect in whole app for all users and non users, only for the current user or just for the time they change the config.

0 likes
6 replies
shez1983's avatar

some of those settings can be changed during run time.. so you could put them in t he db for each admin.. others will have to be changed manually & your php-fpm process needs to be refreshed.

i wouldnt say this is secure.. could be dangerous as well as one mistake could make your site not work for everyone.. what kind of settings are you wanting to be change able?

daglimioux's avatar

Just upload settings. Allow them to select the maximum MB for uploading files, thats all. I will not expose all PHP settings or allow them to break the APP. Just an amount in MB (they also will not be able to change it to GB, for example, to prevent errors when changing the max upload file size).

Btw, the server will be phisically in their office and they will log in as Admins, so is their responsibility.

shez1983's avatar

your web server will not have access to the php.ini file.. ie the phhp-fpm process..

so you might have to spin up a process in the background (cli)

lostdreamer_nl's avatar

Check http://php.net/manual/en/ini.list.php to see which settings can be changed at runtime.

Everything in that list that has 'PHP_INI_USER' or 'PHP_INI_ALL' can be set by calling the ini_set() function and will remain during that single request.

BUT: upload_max_filesize & post_max_size cannot be changed by ini_set() so you will not be able to change those from a script (you might be able to write a .htaccess file with the right settings, but that would be for all users that request from that folder, and only on apache (I should note that it is very bad practise to have PHP write config files for your webserver ).

1 like
daglimioux's avatar

Okay, thank you all for your suggestions. I will then increase the server upload_max_filesize and restrict it by form request rules and create a custom setting for admins, then add a rule like "size:" . Cache::get('upload_setting') . "|mimetypes:video/*"

Please or to participate in this conversation.