ZF2 install via Composer getting wrong PHP version - php

I have to install ZF2 on Windows:
I've clone ZendSkeletonApplication (ZSA) repository from Git
Open cmd and get in ZSA folder
run php composer.phar self-update (everything is ok)
run php composer.phar install
And now I get this:
zendframework/zendframework 2.3.1 requires php >=5.3.23 -> no matching package found.
Okay, I've checked php version php -v:
PHP 5.3.6 (cli) (built: Mar 17 2011 10:37:07)
Any ideas?

ZF 2.3.0 and above requires PHP 5.3.23 or above. You have 5.3.6 (6 is less than 23!). You either need to upgrade PHP to a more recent version, or downgrade to ZF 2.2.x.

5.3.6 is less than 5.3.23. >= means "greather than or equal to".
Zend Framework 2 requires at least 5.3.23, while you have 5.3.6. That means your PHP version is not supported, you can't use the Zend Framework on that server.
What you can do:
Update PHP version to something newer (5.3 is getting pretty old)
If you are sure you already have a newer PHP version installed, check that the cmd is using the new PHP binary and not the old one.

I suggest you update your local Windows version of PHP to the version you are using in production. If that production version is not able to run Zend Framework 2.3.1, you'd not benefit from solving the dependency problem you are experiencing.
Composer does not allow you to change the internally used PHP version if your local PHP is simply used to put together all dependencies but to used to execute these. So matching the production version is a good thing.

Related

Composer issues when running mPDF in PHP 7.4

I get the following error when running mPDF in my browser. I have just installed the latest version of mPDF on my cloud server running PHP 7.4. The requirements page for mPDF say I should be able to run this version with PHP 7.3+
I have tried to resolve the issue in composer.json but have no success. I am not able to install PHP 8.0 without upgrading the hosting which I do not want to do.
Any direction is appreciated.
Error message:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0".
If you would like to learn why the php package is required (this may sound stupid, but think about it as a requirement with a specific version), you can make use of composer-depends(1), a.k.a. why?:
$ composer why php
...
composer/semver 3.2.6 requires php (^5.3.2 || ^7.0 || ^8.0)
doctrine/annotations 1.13.2 requires php (^7.1 || ^8.0)
...
It gives an alphabetical listing of packages in your configuration and which php version they require. This should help you to spot which package requires ^8.0.0 / >= 8.0.0 to get a better understanding.
When your target platform has PHP 7.4, you can configure your project to always depend on that version. This works by specifying the platform php version as a configuration option.
Get the exact php version on your target platform, e.g. 7.4.30 (Aug 2022).
Note: PHP 7.4.x is going to end of life this year[1], consider upgrading the hosting within the next two months to 8.0 at least (if changing hosting for the PHP version is hard, consider to already go to 8.1, test your project with each version first thought, best done locally).
Then within your project configure that version as the projects target platform version:
$ composer config platform.php 7.4.30 # (1.)
# (no output)
1. replace the exemplary version 7.4.30 with your target platform version
After changing the Composer project configuration this way, you need to update the projects dependencies:
$ composer update
# ...
Now Composer will no longer infer the available version of the php platform package (the PHP version) from the environment but instead take the configured platform version. Your local PHP version is not interfering any longer to resolve the installable set of packages. Instead, the configured platform PHP version is used for the resolution.
This effectively prevents that you pull in packages that require a higher PHP version.
Commit all changes to the configuration (composer.json) and pinned versions (composer.lock) and use those to do the packaging for the deployment to the target platform.

Upgrade laravel

Hello after I installed Laravel,
I try to update the version 5.5 to 5.6 and unable to throws me an error:
- laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (7.0.10) does not satisfy that requirement.
I use XAMPP with PHP 7.2.10.
I installed Composer with php 7 And does not help.
Thanks
Have a look at your composer.json. It is possible that there is a configuration parameter config.platform.php which contains the value 7.0.10. This feature allows to simulate a specific PHP version to composer. If you don't need it, you can remove it or force composer to install anyway by using the --ignore-platform-reqs parameter when updating the packages.
If you are on Linux Debian, you can easily install the latest version of php with sudo apt-get install php x.x. On windows, this link might help. Then, try installing or upgrading Laravel from cmd and it should work sweet! Re-installing the latest verion of XAMPP may also do the work for you.
You have to update your system's PATH environment variable so that it finds the newer version of php from your command line. You might have more than one installed right now, so it uses the first one it finds when it looks through the directories defined in your PATH. After updating the path variable, you might have to log out for it to apply.
You can check the version used by your command line with php --version. To see which version Apache is configured with, use phpinfo().

Use the latest Laravel version

Lately l've been working with Laravel. I use composer to install packages and artisan for commands.
The problem is that my machine uses Laravel 5.4 not 5.7.
When i run phpinfo() the result is PHP Version 7.2.7. Do you think that the problem is that i don't use the latest version of xampp which it has included php 7?
Based on comment, yes it is related to PHP version. Your PHP CLI version is too low to support newer version of laravel. You need to update or switch PHP CLI to newer version. Server and CLI PHP are separate packages and might have different versions.
No it is not related to PHP version (in this case).
Probably you ran
composer install
which will install dependencies in versions defined in composer.lock to update dependencies run
composer update
For differences between install and update you can refer to this question
From the comments:
laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.19) does not satisfy that requirement.
Run php -i in the Terminal. Looks like your webserver and your command line (which Composer uses) are using different versions of PHP.
Laravel version depends on your installation way. It's not related to your PHP or XAMPP version. And you are using the latest PHP version, so don't worry about PHP version.
Read the Laravel installation to install the latest version of laravel.
If you using package laravel/installer
Update this package
composer global update
and try to run
laravel new my-app

PHPUnit version with sub PHP 5.3.3

Im running PHP Version 5.3.13.
I installed xDebug Version 2.2.6
Im also using pear.
Im trying to install and use debugging in phpStorm 8, but when I try and start a debugging session I get the following message.
Process finished with exit code 1
Cannot find PHPUnit in include path (.;C:\wamp\bin\php\php5.3.13\pear)
The big issue here is the following PHPUnit 4.4 requires PHP 5.3.3;
Ive checked the versions of PHPUnit back to version 4.0 and all require PHP 5.3.3
My question is this. With my current version of PHP, I dont want to update to 5.3.3 and become a problem for our production environment, but I need to do debugging.
What can I do?
Will going from php 5.3.13 to 5.3.3 have significant effects?
Is there a lower version of PHPUnit available somewhere? (its not listed on their site or in Git)
Your case
Your version of PHP 5.3.13 is actually newer than version required (5.3.3, since 13 > 3) which means you can safely run PHPUnit 4 on your installation and enjoy it.
In general
There is no actively supported version of PHPUnit that is supported on a PHP version earlier than PHP 5.3.3.

Skip composer PHP requirement

We are using PHPCI and composer. The server which runs PHPCI is on PHP 5.3.
For a project we added the Facebook PHP SDK, using composer. It requires PHP 5.4.
Composer gets triggered by PHPCI and get executed. But because the CI server just got PHP 5.3 composer failed with the error message:
facebook/php-sdk-v4 4.0.9 requires php >=5.4.0 -> no matching package found.
This let fail my build in PHPCI, of course.
Is there a possibility to skip this requirement? Maybe by adding an option to composer.json? Or a parameter to composer.phar call?
I've found the option:
composer install --ignore-platform-reqs
Ignore platform requirements (php & ext- packages).
Alternative: Specify your projects' PHP version
You can skip the platform checks by configuring composer.json#/config/platform/php with the PHP version to use.
Composer will fetch packages based on that configured PHP version then.
So when you need to tell Composer the PHP version for your projects dependencies, you can (and should) specify the PHP version if different than the PHP version you execute composer with in your composer.json project configuration file (AKA root package):
{
"config": {
"platform": {
"php": "5.6.6"
}
}
}
Here PHP 5.6.6 version is exemplary, it could be 8.0.4 or any other PHP version.
This also documents the target (platform) PHP configuration. Additionally installed PHP extensions and library versions can be specified.
Compare: Config: platform - Composer documentation
For many commands, you can tell composer to bypass php version check, with parameter "--ignore-platform-reqs":
composer COMMAND --ignore-platform-reqs
this will bypass php version specification.
Be aware that the software may work or not: php version specification is there because somewhere in the code is needed at least the specified php version, so if you use that code the software will break.
If anything requires a specific version of PHP, it won't run in a lower version of PHP. You will properbly still recieve errors when bypassing the PHP requirement.
Btw, PHP 5.3 is no longer maintained, I would strongly recommend updating the PHPCI server.

Categories