1

I am trying to install FOSUserBundle using composer require friendsofsymfony/user-bundle "~2.0" but an error occure :

Fatal error: Out of memory (allocated 1453326336) (tried to allocate 268435456 b
ytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Depe
ndencyResolver/Solver.php on line 220

I have searched about the problem and I have found this answer : Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted

I have changed my php.ini to 1024M but nothing (even composer update generate the same error) then to -1 nothing happend to.

I am wondering where can I found composer.phar to use this command (I have installed my composer via wondows installer):

php -d memory_limit=-1 composer.phar require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

update:

C:\wamp\www\sym>composer diag
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB
723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E32
8C AD90147D AFE50952
OK
Checking composer version: WARNING
You are not running the latest stable version, run `composer self-update` to upd
ate (1.4.1 => 1.8.5)

C:\wamp\www\sym>composer require friendsofsymfony/user-bundle
Using version ^2.1 for friendsofsymfony/user-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocat
e 12 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Compose
r/DependencyResolver/Solver.php on line 220

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-error
s for more info on how to handle out of memory errors.
C:\wamp\www\sym>

IS it a peoblem of wampserver O have wamp 32bit? is it required wapm 64bits?

Julie
  • 563
  • 6
  • 10
  • 23

3 Answers3

1

This is the way I do it

php -d memory_limit=-1 `which composer` require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

You have to use backticks instead of single quotes, but I've never had an issue with it.

You could also use the realpath to your composer.phar file

/usr/bin/composer.phar

or

/usr/local/bin/composer.phar

Useful console commands

J_R
  • 21
  • 9
  • this is the result of the command : Could not open input file: – Julie May 18 '19 at 08:13
  • but why composer create-project symfony/framework-standard-edition project "3.2.*" works fine and other dont? – Julie May 18 '19 at 09:03
  • it could be a wamp problem? I am using 32 bits instead of 64 bits? – Julie May 20 '19 at 09:09
  • @Julie did you make sure you used backticks for `which composer` vs single quotes 'which composer'? Because I get the same error when i use single quotes instead of backticks – J_R May 20 '19 at 15:07
0

Change php.ini value to -1. It will allow composer to use all your free memory. Run composer diag to check composer status and retry composer require friendsofsymfony/user-bundle

If it doesn't work yet, it's probably an internet connection problem

balzacLeGeek
  • 805
  • 5
  • 7
  • I have already tried -1 but it didn't work and I have updated my post using composer diag and trying to reinstall fosuserbundle – Julie May 17 '19 at 14:39
  • This problem is frequent with Windows ... All you can do is to try later :-( – balzacLeGeek May 17 '19 at 14:41
0

There are a few things which will help a lot.

  1. Ensure you are running the latest version of Composer (it says you're running v1.4.1 - that is more than two years old.
  2. Ensure you are running at least a recent version of PHP - version 7 improved the memory use substantially - sometimes halving the amount of memory used. Versions 7.2 or (better) 7.3 should be the versions being used now (spring 2019).
  3. Actively limit the number of different versions of packages that Composer must check to see what could be valid to use.
    • Roave/SecurityAdvisories is a good start. This will also stop you installing versions of packages that have known security issues. It will also limit the search-space for valid packages, allowing Composer to ignore large swathes of possible packages, meaning that it does not need to hold large amounts of data for the various potential combinations.
    • You can add other versions of packages to further narrow the search-space. For example, you may have a number of wildcard "*" versions (also known as 'The Death Star Version Constraint') - which are almost always a bad idea. Mostly, a version number of the form "^2.0" or "^3.4" would be better - allowing upgrades from bug-fix versions and features (the 3rd and 2nd numbers), but not major versions, which can often contain breaking changes.
Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
  • A question please should I install the fosuserbundle under my project wamp\www\my project or under wamp\www because I accidentally execute the commande line : composer require friendsofsymfony/user-bundle "~2.0" under wamp\www and it did work!!!! I am totally confused – Julie May 20 '19 at 11:33