Change php.ini setting in laravel

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Efficiently Changing PHP.ini Settings for Better Laravel File Upload Experiences Introduction: Changing PHP.ini settings is crucial to ensuring your Laravel application runs smoothly, especially when dealing with file uploads where you might need more memory and file size limits. This article aims to provide a comprehensive guide on how to approach these changes in the context of a Laravel project while minimizing potential issues related to PHP updates or server configurations. 1. Identify the Correct php.ini File: The first step is finding the location of your application's php.ini file. This can usually be found within the main folder of your LAMP/WAMP installation, typically in a path like C:\xampp\php\php.ini or /etc/php.conf. To verify that this is indeed the correct version for your Laravel app, run the command "php -i | grep 'Loaded Configuration File'" on your terminal or command prompt to display all loaded configuration files. 2. Checking Current Setting Values: Now, let's check the current values of post_max_size and upload_max_filesize. Run "php -r 'phpinfo();'" in your terminal/command prompt to open PHP Info. Use Ctrl+F to search for "post_max_size" and "upload_max_filesize". Note down their current settings, which will be crucial later when making changes. 3. Changing the Settings in php.ini: Open your php.ini file using any text editor like Notepad++ or VSCode. When editing the file, make sure to only change the values inside the square brackets that are relevant for your project (usually [PHP], [Date], etc.). For example, if you need to increase post_max_size and upload_max_filesize: [PHP] post_max_size = 512M upload_max_filesize = 64M Save the file and close it. 4. Restart Your Server for Changes to Take Effect: To ensure your changes have been applied, restart your server. If you're using WAMP/XAMPP, use the respective control panel to stop and start again. For standalone LAMP installations, you may need to open your terminal/command prompt, navigate into your server directory, and enter "sudo service apache2 stop" followed by "sudo service apache2 start". 5. Verify Settings: Reopen your PHP Info page using the same command ("php -r 'phpinfo();'"). Search for "post_max_size" and "upload_max_filesize" again, and verify that their values have changed to reflect the changes you made in the php.ini file. If they have not been updated, make sure your php.ini file is indeed the one in use by checking the loaded configuration files. 6. Increasing Memory Limit (Optional): If you noticed a memory limit error while uploading your file, increase this as well. Typically found right after post_max_size: memory_limit = 512M Save and restart your server before trying your application again. Conclusion: By following the steps outlined above, you should be able to change PHP.ini settings for better Laravel file upload experiences. Remember that these changes may need to be reverted in future updates or when upgrading PHP versions, so always make a backup of the original php.ini file before making any modifications. For additional assistance with Laravel development and configuration, visit the Laravel Company website for expert guidance and resources.