Laravel - PHP Fatal error when running php artisan serve with increased memory_limit

186 Views Asked by At

I'm encountering a PHP Fatal error in my Laravel project when running php artisan serve. The error message is as follows:

php artisan serve

   INFO  Server running on [http://127.0.0.1:8000].

   Press Ctrl+C to stop the server

   WARN  PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in C:\projects\laravel\storage\framework\views\3013c4ad2c85349d3078c69a5161cf9c.php on line 96.

   WARN  PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 888832 bytes) in C:\projects\laravel\vendor\spatie\ignition\src\ErrorPage\ErrorPageViewModel.php on line 104.

  2023-11-04 15:33:26 .............................................................................................. ~ 15s
  2023-11-04 15:33:26 ............................................................................................. ~ 133s

Mode LastWriteTime Length Name

---- ------------- ------ ----

d----- 11/4/2023 2:50 PM .git

d----- 11/4/2023 2:50 PM .vite

d----- 11/4/2023 2:50 PM app

d----- 11/4/2023 2:50 PM bootstrap

d----- 11/4/2023 2:50 PM config

d----- 11/4/2023 2:50 PM database

d----- 11/4/2023 2:50 PM node_modules

d----- 11/4/2023 2:50 PM public

d----- 11/4/2023 2:50 PM resources

d----- 11/4/2023 2:50 PM routes

d----- 11/4/2023 2:50 PM storage

d----- 11/4/2023 2:50 PM tests

d----- 11/4/2023 2:52 PM vendor

-a---- 11/2/2023 12:25 PM 258 .editorconfig

-a---- 11/4/2023 2:43 PM 1171 .env

-a---- 11/2/2023 12:25 PM 1116 .env.example

-a---- 11/2/2023 12:25 PM 186 .gitattributes

-a---- 11/2/2023 12:25 PM 243 .gitignore

-a---- 11/2/2023 12:25 PM 1686 artisan

-a---- 11/2/2023 3:02 PM 1553 base.txt

-a---- 11/4/2023 2:30 PM 58167 composer-setup.php

-a---- 11/2/2023 12:25 PM 1882 composer.json

-a---- 11/2/2023 12:25 PM 296306 composer.lock

-a---- 11/2/2023 12:25 PM 113 db.sql

-a---- 11/2/2023 12:25 PM 83555 package-lock.json

-a---- 11/2/2023 12:25 PM 415 package.json

-a---- 11/2/2023 12:25 PM 1084 phpunit.xml

-a---- 11/2/2023 12:25 PM 80 postcss.config.js

-a---- 11/2/2023 6:30 PM 4230 README.md

-a---- 11/2/2023 12:25 PM 218 tailwind.config.js

-a---- 11/2/2023 12:25 PM 263 vite.config.js

Here are some details about my environment:

  • Laravel Installer: 5.1.3

  • PHP Version: 8.2.12

  • Operating System: Windows

  • Database: MySQL

I've attempted to increase the memory_limit in my php.ini file from 256M to 512M, but I'm still encountering the same error when running php artisan serve.

I would appreciate any guidance or insights into resolving this issue. Thank you for your assistance!

Additional Information:

  • Laravel Installer: 5.1.3

  • PHP Version: 8.2.12

  • Operating System: Windows

  • Database: MySQL

  • Memory limit in php.ini: memory_limit = 512M

1

There are 1 best solutions below

0
Caio Ladislau On

Open the PHP php.ini file. On Windows, it can be found in the PHP installation folder, such as C:\xampp\php\php.ini if you are using XAMPP.

Locate the memory_limit directive and set a higher value, such as 256M, to allow PHP to use 256 megabytes of memory:

memory_limit = 256M

Save the php.ini file and restart the PHP server (or XAMPP if applicable). Run php artisan serve again, and the PHP Fatal error should be resolved. Adjust the memory_limit value as needed.

Check the PHP settings after the restart using phpinfo() or php -i.