2

I am using Symfony 4...

I run this command:

php -d memory_limit=-1 composer.phar require form

The script runs successfully through these points...

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package symfony/lts is abandoned, you should avoid using it. Use     symfony/flex instead.
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!   // Clearing the cache for the dev environment with debug                       
!!   // true   

Then I get this error:

!!  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Applications/XAMPP/xamppfiles/htdocs/xxxx/vendor/symfony/var-dumper/Cloner/Data.php on line 306

I can run this script without issue:

php -d memory_limit=-1 bin/console cache:clear

I do not know how to get around this because my command is saying to bypass memory limit. What can I do to get beyond this error, I cannot get anything installed at this point.

2 Answers 2

3

When Composer executes script it's a separate PHP call by Composer, so your command line directive doesn't apply to it.

The typical solution would be to configure PHP via its configuration file, so that all instances are affected.

If you don't have access to change PHP configuration your best option is probably to run composer with --no-scripts and then try to run necessary scripts individually with memory limit option.

Sign up to request clarification or add additional context in comments.

1 Comment

Run into thsi as well. I understand the why technicaly but noit the choice behind this.
1

Setting the memory limit for the whole php process might be dangerous, as this could lead to memory problems when executing PHP in a web context. So be sure to only update the configuration for CLI. Composer also provides a configuration point via environment variable COMPOSER_MEMORY_LIMIT You can either set it via export COMPOSER_MEMORY_LIMIT=-1 add it to your .bashrc if you always want to enable it or just prepend the command itself if you only need it once during installation:

COMPOSER_MEMORY_LIMIT=-1 composer require form

You can find all the different ways of getting around memory limit-related problems in Composer's Troubleshooting Guide as well.

2 Comments

I wasn't sure the constant way would apply to script process, but from quick test it does seem to work.
No it does not. Just rna into this issue and digged it with test script. The above assertion is true. It's a separate process. IMHO it should convert the COIMPOSER_MEMORY_LIMIT to php -d memory_limit=xxx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.