2

I try to run phpstan(nunomaduro/larastan 2.6.3) under docker (based on php:8.1.6-apache) in laravel 10.8 app and got memory lack error.

I added memory limit in console command, but error anyway :

root@3ab9f820c86d:/var/www/PostsTagsCRUDTest_DOCKER_ROOT# ./vendor/bin/phpstan analyse  --memory-limit 1M > phpstan.txt
Warning: Failed to set memory limit to 1048576 bytes (Current memory usage is 41943040 bytes) in phar:///var/www/PostsTagsCRUDTest_DOCKER_ROOT/vendor/phpstan/phpstan/phpstan.phar/src/Command/CommandHelper.php on line 101
Memory limit "1M" cannot be set.
root@3ab9f820c86d:/var/www/PostsTagsCRUDTest_DOCKER_ROOT# ./vendor/bin/phpstan analyse  --memory-limit 0.5M > phpstan.txt
Invalid memory limit format "0.5M".

For more details see free(1).
root@3ab9f820c86d:/var/www/PostsTagsCRUDTest_DOCKER_ROOT# free
               total        used        free      shared  buff/cache   available
Mem:         8057500     6022512      483432      201228     1551556     1532956
Swap:        2104476     1424128      680348

In virtualhost.conf of the docker project I got option :

php_value  memory_limit  4048M

If there is a way to fix it ?

1 Answer 1

6

The virtualhost.conf value does not do anything because that's only for your webserver, but you're executing PHPStan from CLI (as you should).

Memory limit "1M" cannot be set because that's a much smaller value than the default (128M).

You can try running PHPStan with the same value you have for your webserver:

./vendor/bin/phpstan analyse  --memory-limit 4048M

That should work.

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

Comments

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.