Thursday, 17 September 2015

Project developing time faced errors in PHP, MySql, and Apache

PHP Fatal Error – yii\base\ErrorException

Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes)


Just add this below line to before line of you getting error in your file
ini_set('memory_limit', '-1');
It will take unlimited memory usage of server, it's working fine.

php.ini changed as follows: memory_limit = 512MB to memory_limit = 536870912


And also to change it via php like so (before error line):

PHP Fatal Error – yii\base\ErrorException

Maximum execution time of 30 seconds exceeded

Edit php.ini

Follow the path /etc/php5(your php version)/apache2/php.ini.
Open it and set the value of max_execution_time to a desired one.

max_execution_time = 360     
 ; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE)

max_input_time = 120          
; Maximum amount of time each script may spend parsing request data

;max_input_nesting_level = 64 ; Maximum input variable nesting level

memory_limit = 128M           
; Maximum amount of memory a script may consume (128MB by default)

All the answers above are correct, but I use a simple way to avoid it in some cases.
Just put this command in the begining of your script:

No comments:

Post a Comment