PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 29, 2022

[FIXED] Is there a difference when running Composer in different versions of PHP?

 January 29, 2022     composer-php, php, vagrant     No comments   

Issue

I have a Vagrant machine with the actual PHP version I want my server to run on, but locally I use a newer version of PHP. Updating Composer locally just saves so much time as opposed to updating it on the virtual machine via SSH.

So my question is: Does it affect the vendor files when composer install or update is called from different versions of PHP?


Solution

The PHP version used when updating the dependencies affects the packages being used. Packages can define a requirement on a certain PHP version.

A common requirement found is requiring PHP 5.4 or 5.5 when a package is using the features of said versions, or PHP 5.3.3 or PHP 5.3.27 because the package needs certain bugfixes.

Composer will complain about not being able to execute composer install if the PHP version used when running this command is not able to fulfill all PHP version requirements that are mentioned in the lock file.

Running composer update with an older PHP version than composer install probably will work in most cases. Using the same PHP version should be the recommended setting, though.

Also: Using the same required extensions in all PHP versions also is needed for requirements checking.

Note that there is some demand for Composer to assume a given PHP version or extension is present on the target platform even if the command line PHP running the Composer command does not fulfill them, but this feature is not implemented yet. So there is no way to override the local PHP version with the one present on the target environment.



Answered By - Sven
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing