Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
this is my second laravel project running on the same machine. the first works just fine.
I use xampp for the projects.
after I install another fresh new version(5.4) laravel, when I run
artisan serve
phpstorm tell me
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in E:\xampp\htdocs*****\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 549
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried
to allocate 262144 bytes) in
E:\xampp\htdocs*****\vendor\laravel\framework\src\Illuminate\Container\Container.php
on line 549
Process finished with exit code 255 at 13:58:28.
Execution time: 4,976 ms.
I tried
other post
about this, and tried to change php.ini. It does not apply to my case.
You must have some kind of bug in your code - e.g. circular reference or other error. Calling
php artisan serve
certainly should not use 130+ MB ram.
Fix the bug and try again... php artisan serve should use a max of say 20mb?
If you really want to run the code, then try
php -d memory_limit=500M artisan serve
which will increase the mem available to php for that particular process.
–
Can you explain a bit more of what your project is about?
I ask because that error is directly related to what a single PHP script is trying to load in memory, i.e.: loading a Model or a File, and the resulting object would use more than the memory allowed per script under the
php.ini
configuration.
Looking at the error, your
php.ini
is set to have a max script memory usage of 128Mb (134217728 bytes/1024 Kb /1024 Mb) and whatever is loading is trying to load an extra 256Kb.
I'd recommend two things
Check your
php.ini
to confirm your memory limits (
memory_limit = ?
)
Provide the full stack trace so we can help you diagnose (
I'm guessing the container is trying to load a model from DB, and the data size is quite large that when loaded, it goes over the limit stablished
)
–
–
You might want to check your Laravel configuration, and ensure that all the configuration files (inside the
config/
directory) are valid PHP.
I had this issue when my
config/app.php
file was missing a '
,
' between two array items.
This doesn't sound like a server setup issue. This is a Laravel setup issue. Increasing memory_limit in the php.ini will not fix the issue in your case. Laravel will commonly throw unhelpful errors if not setup correctly.
After running composer, make sure before you try to run
php artisan serve
that you have done the following.
Root is pointed to
/public
folder
Run composer install. You may be missing some vendor folders
Permissions of
/storage
are
777
.
/storage/logs/laravel.log
<- here you will find your real error.
Make sure to create
.env
aka a copy of
.env.example
Generate a key
php artisan key:generate
Also be careful that you don't have any spaces when creating your variables in your
.env
file this will cause problems as well.
bad
DB_DATABASE=my database name
good
DB_DATABASE=my_database_name
Lastly if you are running something like MAMP you may have to include a
UNIX_SOCKET
variable in your .env file like so:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name_here
DB_USERNAME=root
DB_PASSWORD=root
UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
and create the variable in your /config/database.php file
'mysql' => [
'driver' => 'mysql',
'engine' => null,
'unix_socket' => env('UNIX_SOCKET','')
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.