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

Saturday, January 1, 2022

[FIXED] How to force creating a new Symfony application for a specific PHP version?

 January 01, 2022     composer-php, php, symfony     No comments   

Issue

I want to generate a Symfony application which can be compatible with PHP version up to 7.4.22.

On my local machine, PHP version is 8.0.2 but on the hosting is 7.4.22.

Symfony application is generated from local machine using standard composer command

 composer create-project symfony/website-skeleton my_project_name

I look over create-project arguments to see if I could add some constrains but none seems to be useful.(or didn't figure out)

If try to upload to host the project I get this when trying to install it:

Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.22.

Need just a default empty project to check something on hosting.

I do not want to alter local PHP and doing the same thing on hosting could be troublesome.


Solution

Running composer create-project symfony/website-skeleton my_project_name in an example project using PHP 8 installs psr/cache in v2 and psr/link in v1.1.1. These package versions require PHP 8, and they will not work using any older version of PHP.

To avoid this, just don't run composer create-project with any later version than the one you want to use on your production system (as usually, running it with a lower PHP version than on production yields a set of packages that is compatible with the production system, while the chance is lower the other way around).

Otherwise, check whether there are such package versions using composer why-not php 7.4 before deploying and downgrade them



Answered By - Nico Haase
  • 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