composer update out of memory no matter what I do - macos

I've gone through a bunch of website recommendations and StackOverflow answers and comments to try to figure this out, I'm at a loss now. I'm using a MacBook Pro 2019 with macOS Big Sur (latest), 16GB of RAM, using MAMP Pro with PHP 5.6 or 7.3 (compatible with the repo). The repo last had its composer updated last year.
Me#My-MacBook-Pro the-repo % composer update --verbose
Loading composer repositories with package information
Updating dependencies
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///Applications/MAMP/bin/php/composer/src/Composer/DependencyResolver/Solver.php on line 204
This happens when trying with PHP 5.6 or 7.3, which the repo and my MAMP Pro is compatible with. I use MAMP Pro because it's been the only way I could get these multi-version repos working on my Mac (which started at Catalina, and Homebrew stopped supporting old libraries, and trying to find and compile the correct libraries for PHP 5 on Mac has been a nightmare).
The repo is run on MAMP PRo Apache, PHP 5.6 or 7.3 as CGI, and with the default version set to activate CLI commands with that PHP version. Composer runs the PHP version specified there as far as I can tell. Running php -v shows the expected version either way.
% composer --version
Composer version 2.1.14 2021-11-30 10:51:43
% composer self-update
You are already using the latest available Composer version 2.1.14 (stable channel).
I tried checking https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors, as suggested. Trying those suggestions doesn't help. I upped MAMP Pro's php.ini memory to 4G for both PHP versions. Running printenv shows no COMPOSER_MEMORY_LIMIT var.
% php -d memory_limit=-1 `which composer` update
Could not open input file: composer:
I moved the vendor folder outside of the repo. Same thing. I'm at a complete loss of how to run composer update on this repo. Adding --verbose to the command showed no detailed information, I can't even tell which package it fails on.

I discovered that the problem was caused by me having MB or GB in php.ini instead of just M after the number... so I guess I forgot that bit of unintuitive formatting that PHP has for its memory limit. Silly me.

Related

Composer version downgrade issue

So I am currently trying to set up an old Laravel project, which requires PHP 7.1. I have successfully downgraded from 8.1 to 7.1, but now the composer issue appears:
I am trying to run composer install on a project, in order to install the dependecies needed, but I am facing the composer version error. After running the suggested command, it basically shows the same error, which does not really make any sense. I have tried other commands but seems like the issue is the same.
I am using MAC.
Any idea?
The message tells you that the current version of Composer installed cannot be run with the current version of PHP installed. Even downgrading is not possible.
To overcome this, you could update PHP again to any supported version (as in: 7.2.5 or later), then downgrade Composer to v2.2, then downgrade PHP again to 7.1.
If you want to ease the switch between PHP versions, you could check for a containerized PHP setup using Docker.

Homestead refuses to use specific PHP version (7.1 instead of 8.0)

The Short Version
Laravel application on Homestead is using PHP 8.x as seen in phpinfo(), yet php -v is stating the server is using 7.1 (which is what I want). How is this possible? How do I tell the Laravel application to use 7.1 not 8.x?
The Long Version
I have an older Laravel application (5.8) that I need to upgrade to 8.0. I may be using Shift to do this but I have never done an upgrade manually so I thought I should do that at least once.
So I upgraded Homestead to current (12.x), and everything continued to run fine.
Then I tried to upgrade my PHP version from 7.1 to 8.0 using sudo update-alternatives --config php and chose PHP. Then I verified with php -v that it switched to that version. As expected, I began getting deprecation errors in browser. Knowing I would have to spend some time resolving those I switched back to 7.1... but the errors remained!
I restarted PHP, I restarted the server, I reloaded and reprovisioned the server, I destroyed and reprovisioned the server and absolutely nothing is resolving this issue. I even specified php: "7.1" in the Homestead.yaml file and re-provisioned to no avail.
At this point it seems that the upgrading of Homestead itself is somehow telling PHP to ignore the version I'm specifying it to use. So I know I could downgrade, I suppose, but that isn't really a solution but a band aid. And I'm not certain that will actually work either.
I've tried the Answers in this StackOverflows Change Laravel Homestead v7.0.1 with php 7.2 to php 7.1 including php71.
OS: Windows 10
Homestead: 12.x
This person has an identical problem and resolved it with Docker somehow but I don't understand how to translate that to Homestead.
There is PHP-CLI and PHP-web. PHP-CLI version is what is reported when using php -v but PHP-CLI is what NGinx is using, hence getting 8.0 when using phpinfo() in ~/public/index.php
To resolve the issue I manually updated /etc/nginx/sites-enabled/mysite and edited line below location where it says fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; to say fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; and then I restarted PHP with sudo systemctl restart nginx.

Unable to configure Homestead per-project with Laravel 6 on PHP <7.1

I'm setting up a Laravel 6 project to use Homestead per-project, but running into a Catch-22 when cloning the repo on a machine without PHP 7.2 installed locally.
The issue is that Laravel 6 requires PHP 7.2 (I have 7.1 installed locally), which means composer update will not work locally:
This package requires php ^7.2 but your HHVM version does not satisfy that requirement.
which means I cannot vagrant up to get to the Homestead box (that includes PHP 7.2) without having run composer update:
Message: LoadError: cannot load such file -- /Users/.../.../vendor/laravel/homestead/scripts/homestead.rb
which means I cannot get anything working.
To get around this, I either have to a) upgrade my local machine to PHP 7.2 to be able to run composer update or b) install Homestead separately and run vagrant up from there, both of which bypass the benefit of a per-project set up.
Is there something I'm missing to get this configuration to work?

How to install mpdf v8 with composer (currently it only installs v6)

I am on ubuntu 12.04 and trying to install the latest release (v8) of mPDF using the following command:
composer require mpdf/mpdf
However, only v6 gets installed.
Is there any easy way to install version 7 or 8 of mPDF - or is it quite a long process?
UPDATE
After running composer require mpdf/mpdf:^8.0
it looks like the PHP version on the server is 5.3.0.
Although none of the domains on the server use this (I use plesk to force all domains to use 7.1).
The PHP version on the server was a lot older than used by plesk.
As composer was looking at the older version, we could download a more recent version of mpdf.

Composer very slow on one computer, no problem on others

Been having issues on a particular Linux machine with the composer package manager. On this particular machine, it seems it can't download anything from repo.packagist.org/p. The download speeds I get are 10~15KB/s
Ubuntu 18.04
Composer 1.7.3
PHP 7.2
It appears to be a mirror issue (this machine not selecting different, if that's even a function)
The following solves it temporary:
composer config repositories.packagist.org composer https://repo-eu-uk-1.packagist.org

Resources