PHP - symfony/console library thorws deprecated error with 8.1 - php

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.

Related

I cant install phpspreadsheet using composer

I am trying to make an import excel data to mysql using php and trying to install composer require phpoffice/phpspreadsheet
but the error below always appear.
Installation failed, deleting ./composer.json.
In RequireCommand.php line 217:
No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.
In PackageDiscoveryTrait.php line 313:
Package phpoffice/phpspreadsheet has requirements incompatible with your PHP version, PHP extensions and Composer version:
- phpoffice/phpspreadsheet 1.25.2 requires ext-zip * but it is not present.
At First, I thought i was because of my php version. I am running xampp with php 7.3 on my macOs. it didnt work.
I try to install it in my windows PC which run php 7.4 and it work just fine.
So I remove my 7.3 version and install the 7.4 version into my mac. and it didnt work either.
There is no compomposer.json in the directory.
When starting a new project, you should at first run
composer init
It will do some question to initialize the value in composer.json, which basically are the same you can pass as parameter to the command: https://getcomposer.org/doc/03-cli.md#init
After that you can run composer to install package
avoid using same name in folder and before installation use composer init

Composer update gives error phpunit/phpunit

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 !

windows - Root composer.json requires PHP extension ext-gd * [duplicate]

This question already has answers here:
How do I install GD on my windows server version of PHP
(8 answers)
Extension gd is missing from your system - laravel composer Update
(23 answers)
Closed 2 years ago.
Good afternoon
Sorry I don't speak english, but I will try to communicate using google translator
To start, it should be important to inform that I use windowns 10, and php 7.2
I'm trying to put some form of payment on my system!
However when typing the command
php composer.phar require "mercadopago/dx-php"
or
composer require "mercadopago/dx-php"
give the following error
You are running Composer with SSL/TLS protection disabled.
Using version ^2.2 for mercadopago/dx-php
./composer.json has been updated
Running composer update mercadopago/dx-php
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires PHP extension ext-gd * but it is missing from your system. Install or enable PHP's gd extension.
Problem 2
- mpdf/mpdf is locked to version v7.1.9 and an update of this package was not requested.
- mpdf/mpdf v7.1.9 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.
Problem 3
- spatie/array-to-xml is locked to version 2.16.0 and an update of this package was not requested.
- spatie/array-to-xml 2.16.0 requires php ^7.4|^8.0 -> your php version (7.2.23) does not satisfy that requirement.
Problem 4
- league/flysystem 1.1.3 requires ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
- laravel/framework v5.6.40 requires league/flysystem ^1.0.8 -> satisfiable by league/flysystem[1.1.3].
- laravel/framework is locked to version v5.6.40 and an update of this package was not requested.
To enable extensions, verify that they are enabled in your .ini files:
- C:\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I gave the following command composer require "ext-gd:" --ignore-platform-reqs* and it happens
You are running Composer with SSL/TLS protection disabled.
./composer.json has been updated
Running composer update ext-gd
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package jpgraph/jpgraph is abandoned, you should avoid using it. No replacement was suggested.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Class App\agentes located in C:/xampp/htdocs/analiselol - Copia/app\Agentes.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Aportes located in C:/xampp/htdocs/analiselol - Copia/app\aportes.php does not comply with psr-4 autoloading standard. Skipping.
Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
You can run ".\vendor\bin\upgrade-carbon" to get help in updating carbon and other frameworks and libraries that depend on it.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover
Warning: PHP Startup: Unable to load dynamic library 'php_curl.dll[PHP]' (tried: C:\php\ext\php_curl.dll[PHP] (No foi possvel encontrar o mdulo especificado.), C:\php\ext\php_php_curl.dll[PHP].dll (No foi possvel encontrar o mdulo especificado.)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'php_curl.dll[PHP]' (tried: C:\php\ext\php_curl.dll[PHP] (No foi possvel encontrar o mdulo especificado.), C:\php\ext\php_php_curl.dll[PHP].dll (No foi possvel encontrar o mdulo especificado.)) in Unknown on line 0
Package manifest generated successfully.
56 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
In php.ini i took it out; of the following line
extension = php_gd2.dll
and as I didn't have the line extension=php_gd2.dll I added it there in an attempt to resolve
I'm new to this part of the programming, if you missed something important, I'm sorry, I really need to make it work!
a and follow my composer.json, if it matters

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

How to install zend framework on Ubuntu?

I want to install zend framework on the Ubuntu and i have followed the instruction of installation from
http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html
link but failed to install.
I have downloaded the ZendSkeletonApplication from here
https://github.com/zendframework/ZendSkeletonApplication
After that run of this command
php composer.phar self-update // it's working
But after the first command the second Command
php composer.phar install // Not working
And showing this error
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- zendframework/zendframework 2.3.1 requires php >=5.3.23 -> no matching package found.
- zendframework/zendframework 2.3.0 requires php >=5.3.23 -> no matching package found.
- Installation request for zendframework/zendframework 2.3.* -> satisfiable by zendframework/zendframework[2.3.0, 2.3.1].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Update after some comments:
Now I've downloaded the ZendSkeletonApplication-master and move the
Library folder of ZendFramework-2.3.1
in the
ZendSkeletonApplication-master/vendor/ZF2/
But after that when i access this i'm getting this error on the page
ZendSkeletonApplication-master/public/index.php // in the browser it showing me this error
Fatal error: Declaration of Zend\Stdlib\ArrayObject::offsetGet() must be compatible with
that of ArrayAccess::offsetGet() in /var/www/html/demo/username/ZendSkeletonApplication
-master/vendor/ZF2/library/Zend/Stdlib/ArrayObject.php on line 22
Well two solutions are possible :
First upgrade php, However it could be possible that Ubuntu release on your system not having upgrades for php. So in that case search google to add APT repository for php 5.3.23 for your ubuntu-VERSION.
Second I personally experienced that, Checkout in folder you will found composer.json file, In that file you will get the settings something like
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": "2.3.*"
}
Just change settings to get other version of ZF2
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.*"
}
It works for me. It should work for you.
Read the error, the main thing we need to focus on is this:
zendframework/zendframework 2.3.1 requires php >=5.3.23 -> no matching package found.
I'll break it down for you.
This states that the package you are attempting to install(zendframework/zendframework 2.3.1) REQUIRES a php version GREATER OR EQUAL TO 5.3.23. As your php -v output stated, you are running PHP 5.3.10. If you are running on a local server that you have access to updating the php version, then update php and run it again, you should see that it works fine. If you are on a remote server, contact your hosting company and see if they can upgrade you to a newer version of php and then run it again!
Hope this helps!
If you have more then one version of php installed and you have php environment variable linking to an old php executable then you may get this issue. Change your environment variable to the php you want to use.

Categories