PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 19, 2022

[FIXED] How to increase memory limit in php 7

 April 19, 2022     apache, composer-php, laravel, php     No comments   

Issue

I have hit the error

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors

While trying the code:

composer require laravel/passport

in my laravel project.

I have tried following the instructions in the link but I am unable to increase my memory limit because I cannot find the file php.ini in my /etc/ directory. I can only find php.ini.default and I have increased the memory limit there to 900MB. I have restarted apache for the new configuration to reflect but the limit still shows 128MB which is what it has always shown in when I run the command:

php -r "echo ini_get('memory_limit').PHP_EOL;"

How can I get this fixed? My php version is 7.3.9

I must also mention that the issue I have is peculiar to a particular project. I have been able to successfully run

composer require laravel/passport

in another project


Solution

Try renaming the php.ini.default to php.ini. PHP doesn't load it if it has the .default extension. You can run php --ini in your console to see which ini files are loaded. Your php.ini should be in this list, otherwise just add the memory limit setting to another file in this list.

There can also be a case where there are two different ini configs, one for cli and one for web. If you have both make sure you're editing the correct one. If you've got php-fpm installed you'll most lkikely have a php.ini in /etc/php/7.3/fpm and /etc/php/7.3/cli.

If all of the above doesn't work you can always try to just reinstall your vendors:

  • delete your vendor folder
  • delete your composer.lock (composer's cache)
  • add the passport requirement manually to your composer.json (e.g. "laravel/passport": "^7.3")
  • and finally run composer install, installing everything again.


Answered By - akalucas
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing