Switch php versions on start composer update - php

I have PHP v7.4 on Ubuntu server. And I have an alternative PHP in the path /opt/php81/bin/
I need to start command composer update with PHP 8.1
I tried like that /opt/php81/bin/php composer update but I see the error
Could not open input file: composer
I tried that /opt/php81/bin/php composer update --working-dir=/var/www/user/data/www/myweb.site
and I see the same error.

I found that this solution works !
/opt/php81/bin/php /usr/local/bin/composer update --working-dir=/var/www/user/data/www/myweb.site

Related

Laravel composer install giving error "Your lock file does not contain a compatible set of packages please run composer update"

I have been writing laravel code for quite sometime. Currently, I tried cloning a project from github and editing locally. I installed composer in my project directory but a vendor folder was not included, I tried to run composer install but I gives me this error
Your lock file does not contain a compatible set of packages. Please run composer update
How do I resolve this?
Note: I have tried running composer update on previous clones and that didn't work.
Run this command:
composer install --ignore-platform-reqs
or
composer update --ignore-platform-reqs
Disclaimer, this solution will not fix the issue for PHP 8 projects.
In most cases this happens because of PHP 8 (In my case it was GitHub CI actions automatically started using PHP 8 even though my project is php 7.4)
If you have multiple PHP installations (E.g. 7.4 and 8 on the same server), this is how you can fix it.
Specify your php version in your composer.json file
"config": {
"platform": {
"php": "7.3"
}
},
If you have the lock file already committed, run composer update after you adding above line in to the composer.json and then commit the new lock file. (Please be aware composer update will upgrade your packages to latest versions)
I solved this problem with this command:
composer self-update --1
It probably works because at time that the project was developed, composer was on another version and when change the Major version from 1 to 2 the compatibility was broke. With this command you downgrade composer and probably going to solve this
You should try running composer update --lock that will update all packages and recreate the compose.lock file.
Either you can delete the composer.lock file and run composer install that will also recreate the .lock file.
This resolved my issue.
I had this error with Github Actions trying to deploy a Laravel app, this is probably different than the OP's case but none of the suggestions worked for me. Adding my answer here just in case there is someone else out there with a similar problem to mine.
I had to disable -q in Github Actions and see that it was complaining about extensions not being installed.
Make sure your require section of composer's php extensions matches the extensions: in your github action file for shivammathur/setup-php#v2 and it will deploy again
Recently I've just come across of this error when I tried to run my Laravel 7 project which required php v7.* with php v8. As I forgot my php version I just tried bunch of composer command, but just got error after error.
Anyway, to solve this just downgrade/upgrade php version as required. Just search how to do that in youtube.
you can see your project required php version in composer.json file (just if you wonder)
Also you can try following way (But though it didn't worked for me, seems it helped quite some people)
-- Open composer.json file and change php version to something like this: "php": "^7.3|^8.1"
-- Then run composer update
I faced this problem with my cakephp project in garuda linux (arch based)
Fix :
Install php-intl using sudo pacman -S php-intl
Enable php intl by editing php config ( in my case /etc/php/php.ini ) .
add extension=intl or uncomment the existing one
restart apache or whatever you are using
I had the same error deploying another project with composer, but the problem was a missing php extension.
I understand you solve your problem but for anyone seeing the same error message, here is a general guidance :
The error message Your lock file does not contain a compatible set of packages. Please run composer update is shown each time there is a conflict during the dependency solving step of composer install. (see the relevant part in composer source code)
It doesn't inform on the real problem though, and it could be hard to guess.
To get the exact explanation you can add --verbose option to composer install command (the option is available to any composer command (see the doc)) : composer install --verbose
It will give you the full message explaining what exactly is preventing composer install from completing (package version conflict, missing php extension, etc.), then you'll be able to fix the problem.
Hope this could help.
In my case this problem is occuring in Ubuntu 20.04 Desktop. This is due to some missing packages.
I ran the following commands to install some packages then rerun Composer install and its working properly. The commands are:
sudo apt-get install php-mbstring
sudo apt-get install php-xml
Then rerun composer install

How to fix this scsuoft/laravel-exception-notification error?

I am using PHP version 7.2.19 and Laravel 5.6.39. I am getting this scsuoft/laravel-exception-notification error when I run composer install.
When I check the link it is not available and I also try to delete the scsuoft file manually but when I run composer install again the file is automatically added and I keep getting the same error.
Also, if I try composer require jeremykenedy/laravel-exception-notifier
Try composer require jeremykenedy/laravel-exception-notifier. After some digging i found there's no scsuoft/laravel-exception-notification anywhere.

Getting error during use of composer installation on windows

I have executed the following command on windows command prompt
folder path >php composer.phar install
Getting Error
Could not open input file: composer.phar
Your command is trying to use composer which is not installed. It is not used to install composer. You have to install it using one of methods stated here:
https://getcomposer.org/doc/00-intro.md
The other option is that your path to composer file is wrong, which can also be fixed by following documentation.

Could not open input file: composer.phar

I am trying to install zendframework using composer tool in wamp server.
The following steps are done towards installation
I downloaded the Composer-Setup.exe file from composer page and got successfully installed.
I downloaded the zendframework and extracted inside the c:\wamp\www\zend folder
I executed the command for self update
php composer.phar self-update
This line generates the error message: could not open file composer.phar
how to resolve this error
If I try the
composer.phar self-update
Use this :
php -r "readfile('https://getcomposer.org/installer');" | php
This will install composer to the current directory so that you can use php composer.phar
The composer.phar install is not working but without .phar this is working.
We need to enable the openssl module in php before installing the zendframe work.
We have to uncomment the line ;extension=php_openssl.dll from php.ini file.
composer use different php.ini file which is located at the wamp\bin\php\php-<version number>\php.ini
After enabling the openssl we need to restart the server.
The execute the following comments.
I can install successfully using these commands -
composer self-update
composer install --prefer-dist
I was trying to install YII 2.0
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha
I got the same error:
Could not open input file: composer.phar
Then i gave the full path of .phar like this:
php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-alpha
and it worked.
I am using Windows 7, and I got the same problem as yours while using Composer via cmd.
The problem is solved when I use
php C:\ProgramData\ComposerSetup\bin\composer.phar create-project slim/slim-skeleton
instead of
php composer.phar create-project slim/slim-skeleton
Hope this is useful for people who got the same problem.
First try this: dont use the php composer.phar [parameters] simply use composer [parameters] if this doesn't work for you than try the rest. Hope it helps.
Question already answered by the OP, but I am posting this answer for anyone having similar problem, retting to
Could not input open file: composer.phar
error message.
Simply go to your project directory/folder and do a
composer update
Assuming this is where you have your web application:
/Library/WebServer/Documents/zendframework
change directory to it, and then run composer update.
Initially, I was running php composer.phar self-update and got the same error message.
As a resolve, you should use composer command directly after install it.From the command prompt, just type composer and press enter.
If composer is installed correctly then you should able to see a lot of suggestion and command list from composer.
If you are up to this point then you should able to run composer self-update directly.
Try in command line:
curl -sS https://getcomposer.org/installer | php
dont use php composer.phar self-update
First go to Your project directory
simply use composer.phar self-update
This works for me
I have fixed the same issue with below steps
Open project directory Using Terminal (which you are using i.e. mintty )
Now install composer within this directory as per given directions on https://getcomposer.org/download/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'the-provided-hash-code') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Now run your command.
Everything is working fine now because the composer.phar file is available within the current project directory.
Copied from https://stackoverflow.com/questions/21670709/running-composer-returns-could-not-open-input-file-composer-phar/51907013#51907013
thanks
This is how it worked for me:
Make sure composer is installed without no errors.
Open "System Properties" on windows and go to the "Advanced" tab. (You can just press the windows button on your keyboard and type in "Edit the system environment variables`
"Environment variables"
Under "System variables" Edit "PATH"
Click on "New".
Type in: C:\ProgramData\ComposerSetup\bin\composer.phar
Close all folders & CMDs + restart you WAMP server.
Go to whatever directory you want to install a package in and type in
composer.phar create-project slim/slim-skeleton
for example.
If you go through the documentation, they have mentioned to use php composer.phar
Link: https://getcomposer.org/doc/03-cli.md#update-u
Don't use php composer.phar
only give composer
Command: composer self-update
It will work.
Instead of
php composer.phar create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application path/to/install
use
php composer.phar create-project --repository-url="https://packages.zendframework.com" zendframework/skeleton-application path/to/install
Just add https instead of http in the URL. Though it's not a permanent solution, it does work.
Another solution could be.. find the location of composer.phar file in your computer. If composer is installed successfully then it can be found in the installed directory.
Copy that location & instead of composer.phar in the command line, put the entire path there.
It also worked for me!
I had the same issue when trying to use php composer install in a local directory on my Apache server for a laravel project I cloned from Github. My problem was I had already setup composer globally on my Ubuntu 18 machine. Adding sudo instead of php started the install of a whole slew of packages listed in the json.lock file i.e. sudo composer install.
Just Use composer install
composer install

Composer on Windows 7 (x64) PHP 5.4.7

I'm not new in composer and PHP I already used it a lot of time on Linux and on Windows too, but today I encountered a problem.
Today I tried to use composer update / composer install on my Windows 7 and then I got an exception: "Composer could not find the config file:" it is strange, because it was working few days ago.
I tried use the newest composer.phar and also tried use composer installed by Composer-Setup.exe, also I tried put composer.phar on different location (project location etc) it always throwing me the same exception.
When I run composer validate command I've got: ./composer.json is valid, so composer.json was found and is valid.
Thanks for all answers
delete composer path and variable from enviroment variables and reboot (restart) Windows. Then add variable and path again

Categories