Composer very slow on one computer, no problem on others - composer-php

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

Related

using Doctrine in localhost works well but after uploading to C-panel, below error accrued

Uncaught Error: Class "Symfony\Component\Cache\Adapter\ArrayAdapter" not found,
but Symphony cache and Doctrine cache has been installed,
my composer.json:
"doctrine/orm": "^2.11.0",
"doctrine/dbal": "^3.2",
"doctrine/annotations": "1.13.2",
"symfony/yaml": "^5.4",
"symfony/cache": "^5.4"
This is most likely because of version differences between your local and hosted environments, e.g. you might be running PHP 7.x locally and PHP 8.x on your hosted environment. This can be a bit of a struggle. The key things you need to know are:
composer.json keeps a list of packages that you have said that your project needs. This is usually listed as point revisions, e.g. 1.x, 2.x, 3.x
composer.lock lists the EXACT versions of the package that was installed when the composer install (or composer upgrade) command was used, e.g. 1.2.3
vendor/ is the resulting folder that was installed as the result of running composer install
When there is no composer.lock file, or composer upgrade is run, then composer will fetch the latest version of the available libraries based on the current environment, e.g. your local machine. If you then pick up the vendor/ folder and upload it to your hosted environment, it may contain code that isn't compatible with the environment there.
I see people recommending to delete the composer.lock and vendor folder on the production machine, and then run composer install again. This is likely to resolve the issue, but it glosses over the fact that the code you're running in production is then different to what you were developing locally. On shared hosting it may not be immediately obvious how to run composer install as you may need access to a shell (e.g. SSH connection)
There are two ways forward - either:
use your control panel to change the PHP version for your site to a version that you are running locally
change your local dev environment to run the same version of PHP that your hosting environment is running
Be sure to always run the same version of PHP on dev and production to avoid these kinds of problems, and take the time to understand the purpose of composer.lock and how it is used to populate the vendor/ folder with the exact code based on your current PHP version.

composer update out of memory no matter what I do

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.

"database/seeds" error when running "composer global require laravel/valet"

I'm running Ubuntu 18.04.4 LTS (Bionic Beaver).
I have installed Composer, Laravel, among other things on this server. I'm trying to run:
composer global require laravel/valet
It attempts to run, and outputs:
Changed current directory to /home/myUser/.config/composer Using version
^2.9 for laravel/valet ./composer.json has been updated Loading
composer repositories with package information Updating dependencies
(including require-dev) Nothing to install or update Generating
optimized autoload files
In ClassMapGenerator.php line 69:
Could not scan for classes inside "database/seeds" which does not
appear to be a file nor a folder
Where is/should this folder be, and why wouldn't it already be there anyway?
Laravel Valet is a MacOS utility, there are linux ports, such as this one, but it won't work on Ubuntu as it uses Homebrew under the hood, a package manager for MacOS.

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?

Manually install Parse PHP SDK without Composer

I've got a client on a shared hosting environment (which I can't change) and I'm needing to install the Parse PHP SDK, but the host won't allow me to install the Composer package manager. Does anyone else know of a manual install method?
If you have wget/unzip available, just download latest release zip (bellow the release, this file).
Use unzip to unpack package and load it with PSR-4 autoloading (the composer's approach).
Composer isn't meant to be an installer, so you are not expected to run Composer on the production machine. What would happen if during your update process Github would be down? No new website version! And maybe also no old version.
Run Composer somewhere else, and then upload the result to the server, after you verified that everything went well.

Resources