Composer update gives error phpunit/phpunit - php

I recently installed php (8.1.7) and composer (2.3.7) and laravel 9;
Now I am getting this error while running the command
composer update
on a laravel project, I searched a lot but couldn't find exact solution, all of them were not discussing the issue of phpunit/phpunit.
The error looks like this:
Problem 1
- phpunit/phpunit[6.0.0, ..., 6.5.14] require php ^7.0 -> your php version (8.1.7) does not satisfy that requirement.
- Root composer.json requires phpunit/phpunit ~6.0 -> satisfiable by phpunit/phpunit[6.0.0, ..., 6.5.14].```

You have to upgrade your phpunit version to correspond with your php 8.1.7 (choose between phpunit version 9 or 8, according to the official documentation) or downgrade your php version to works with phpunit 6.*.
That's it !

Related

Old Laravel project is not working after a while, What can I do to make it running again?

I have an old project and I am not the person that worked on it
I need to run it again but it's giving me this error
This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
I tried to run composer update but it gives me this error
Problem 1
- Root composer.json requires php ^7.1.3 but your php version (8.1.5) does not satisfy that requirement.
Problem 2
- laravel/framework[v5.6.0, ..., 5.6.x-dev] require php ^7.1.3 -> your php version (8.1.5) does not satisfy that requirement.
- Root composer.json requires laravel/framework 5.6.* -> satisfiable by laravel/framework[v5.6.0, ..., 5.6.x-dev].
You can do composer install by following command
composer install --ignore-platform-reqs --no-script
Also another way can be to update your composer.json php version to 8 or downgrade your system php version to php7.
Hope it works.

PHP - symfony/console library thorws deprecated error with 8.1

When running my PHP project which is now using version 8.1. I get the error:
PHP Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/XAMPP/xamppfiles/htdocs/project-core/vendor/symfony/console/Helper/HelperSet.php on line 111
Tried:
php composer.phar update vendor/symfony/console
and got the same error.
Also tried:
composer update symfony/console
and I got conflicts like:
Problem 1
- facebook/webdriver is locked to version 1.2.0 and an update of this package was not requested.
- facebook/webdriver 1.2.0 requires php ^5.5 || ~7.0 -> your php version (8.1.4) does not satisfy that requirement.
Problem 2
- cakephp/collection 3.10.1 requires php >=5.6.0,<8.0.0 -> your php version (8.1.4) does not satisfy that requirement.
- robmorgan/phinx 0.10.8 requires cakephp/collection ^3.6 -> satisfiable by cakephp/collection[3.10.1].
- robmorgan/phinx is locked to version 0.10.8 and an update of this package was not requested.
I also checked THIS LINK. Can someone help me figure out this problem?
I have also seen THIS but I do not think it solves the issue as I can not edit vendor files..
It could be that composer itself needs to be updated, rather than the dependencies you are trying to install.
Upgrading composer v2.0.9 to v2.5.0 was the fix I needed to silence deprecation notices mentioning symfony.
Depending on how you installed composer, and whether you've renamed the phar to just composer and put it in your path, that is done with:
php composer.phar self-update
or
composer self-update
Add sudo if permissions require.

Running 2 Symfony projects with different php versions

I'm working on a Symfony (4.4) project with PHP version(7.1.30) and now I want to start a new Symfony (5.0/5.1) project.
But I could not do it because it wants at least PHP 7.2.5. (Windows 10 machine).
I have installed PHP 7.3.6 and added it to the PATH environment. But when I try to create the new Symfony project I get this error:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- symfony/symfony v5.0.2 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement.
- symfony/symfony v5.0.1 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement.
- symfony/symfony v5.0.0 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement.
- Installation request for symfony/symfony ^5.0 -> satisfiable by symfony/symfony[v5.0.0, v5.0.1, v5.0.2].
Can you please advise how can I use 2 different PHP versions for the different projects?
(I can't upgrade the 'old' project because some extensions cannot work with 7.2.5)
To run composer with an older php version, download an appropriate phar of composer for that version. The latest is probably compatible with all versions, but if it doesn't work download an earlier version until it starts working.
Then run the non default php with the following command in the composer.phar directory(replace C:\php7.2.5 with your actual path):
C:\php7.2.5\php.exe -c C:\php7.2.5\php.ini composer.phar update
If you use git bash(what I do)
/c/php7.2.5/php.exe -c /c/php7.2.5/php.ini composer.phar update
You can also make this into a batch or bat file pretty easy.
The -c flag is to point to the correct php.ini.
You can select the php version for the project with
echo 7.4.10 > .php-version
When you create the .php-version for each project you can run the server as you run it usually and everything works fine
Also, when I use 7.4.10 locally, I have to use my commands like this
symfony php bin/console make:migration
with symfony before php bin/console

Latest Laravel and latest WAMP issues

I have them both vanilla setup. Laravel setups up fine. But when i run composer install i get;
> Problem 1
- This package requires php ^7.1.3 but your PHP version (7.0.11) does not satisfy that requirement.
Problem 2
- Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].
- doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.11) does not satisfy that requirement.
Problem 3
....
Problem 24
- Installation request for sebastian/diff 3.0.1 -> satisfiable by sebastian/diff[3.0.1].
- sebastian/diff 3.0.1 requires php ^7.1 -> your PHP version (7.0.11) does not satisfy that requirement.
Problem 25
- laravel/framework v5.6.26 requires php ^7.1.3 -> your PHP version (7.0.11) does not satisfy that requirement.
- laravel/tinker v1.0.7 requires illuminate/console ~5.1 -> satisfiable by laravel/framework[v5.6.26].
- Installation request for laravel/tinker v1.0.7 -> satisfiable by laravel/tinker[v1.0.7].
A total of 25 problems when running composer on laravel...
I have understood so much my php version differs in minor version, but what can i do to fix it?
Thanks!
I think your laravel version wants php version >= 7.1.3 but your installed version is 7.0.11.
If you have installed latest laravel version i.e(5.6) then it should match following requirements:
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
Please check laravel installation guide https://laravel.com/docs/5.6/installation#installation
Yea, there where mismatches in version. Strangley enough i downloaded another phpversion 7.2.xx. And it almost worked like a charm. They have some strange things going on eg. the extensions config directive s never prefixed with "php_" in the ini file and it is very easy to miss, so you will need to add it yourswelf also there are no extension dir config by default, you also need that one. Its commented out, another workhour to find this this.
Thanks for your reply!

yii2 : xampp upgrade to php7

I have a new project in yii2, I downloaded yii2 using composer and when I try to download the extension it tells me to upgrade my PHP from 5 to 5.6 or higher. Then I upgraded it to 7.1.3 the old projects works fine and the phpMyAdmin too afterwards I tried to install the extension again. It gives me the same message.
Problem 1
sebastian/version 2.0.1 requires php >=5.6 -> your PHP version (5.5.34) does not satisfy that requirement.
sebastian/version 2.0.1 requires php >=5.6 -> your PHP version (5.5.34) does not satisfy that requirement.
Installation request for sebastian/version (installed at 2.0.1) -> satisfiable by sebastian/version[2.0.1].
What is wrong here?

Categories