Change php version on windows

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change php version used by composer on windows #6277

Change php version used by composer on windows #6277

Comments

I don’t understand why my composer is using a 5.4.45 php version when i don’t see such version on my computer, i use wamp with php 5.6.25 , in my environmemt variable i have the this version on top of the list of path value.
Is there a want to change the version composer is using please ?

The text was updated successfully, but these errors were encountered:

@crashbdx the PATH value should contain the directory of the php.exe, not the full path including php.exe, just in case there is some confusion there.

Composer is not at fault in any case as this is OS/shell-level resolution.

If you’re on windows you can type where php to see which php is used, or in bash on linux/OSX type which php .

@crashbdx the only way is to uninstall and install it again 😉

@alcohol @Seldaek it would be nice if there were an option to change the following option without having to uninstall => install:

2017-07-05_1025

@denisdulici such requests should really be posted to composer/windows-setup. Then @johnstevenson can have a look at it and see how feasible it is 🙂

the only way is to uninstall and install it again 😉 work for me

You can change php version of composer without uninstalling it, follow these steps :

  1. Search for system environment variables in cortana.
  2. Click on the button «Environment variables».
  3. Under «System variables» select path and click on edit, you will see one entry like this «C:\wamp\bin\php\php5.6.13».
  4. Just change this to the folder name of the php located at your wamp/bin/php7.1.9, here bin7.1.9 is folder name.
  5. Replace php5.6.13 with bin7.1.9, it will look like these «C:\wamp\bin\php\php7.1.9», just click ok on all the boxes.
  6. You are done.
  7. To verify, first close all the cmd windows, than open cmd and type «php -v», press enter and you should see php7.1.9.
  8. If you don’t see change in php version than just restart your pc and run php -v again in cmd , it will work.

IMO there is no need to switch the environment variables just for running composer commands with a different PHP Version (which were not set in your env paths.). Just run your composer.phar with a absolut PHP execution file path and you will be fine. Command pattern: $ install .

Читайте также:  Php get classes in directory

This should do it if you have composer installed globally:

  • On windows e.g.: C:\xampp\php\php.exe C:\ProgramData\ComposerSetup\bin\composer.phar install
  • On *ngix run e.g.: /usr/bin/php /usr/local/bin/composer install

DependencyResolver easily eats up over 1GB and 32bit php is limited to 2GB memory use and oddly enough I get fatal errors near 1.3GB, so I have to use a 64bit php just for composer.

So according to this (and this: composer/windows-setup#72) topic the devs apparently don’t care about this sort of problem and want you to change your whole system’s environment to a different php. noice.

The only workaround seems to be the one mentioned by @linslin even though one can end up with monsters like this (using GitBash on windows):

/c/php/php-7.2.9-Win32-VC15-x64/php.exe -d memory_limit=-1 «c:\ProgramData\ComposerSetup\bin\composer.phar» update

Really, am I supposed to write this instead of «composer update»? Legit.

image

check out this i have composer installed and php command working on my pc but there is no php in path variable

@RahulDey12 check both the user list and the system list. Both provide values for the PATH variable.

Same has @RahulDey12 I can’t find it, even on user list and system list! Where the heck did Composer created that link 😲 ?

Hi. My project is has this error. «Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version «>= 8.1.9». You are running 8.0.22. in C:\OSPanel\domains\task-manager\vendor\composer\platform_check.php on line 24″

Источник

How to change PHP version in XAMPP for Windows

Image of PHP 7

Have you ever wondered how to upgrade or downgrade your PHP version in XAMPP without having to install another XAMPP software?, Well i have and from most answers i saw online, the best option was to download an updated version of XAMPP, but looking at it, i knew there had to be a better way so i made some research and was able to figure it out. In this article, i would show you how i changed my PHP version from 7.4.15 to 8.0.19. This is a screenshot of my current PHP version If you don’t know your current PHP version, you can use this link to check it.

STEP 1

PHP non thread safe version

Download the PHP version you want to use, you can find the PHP version you want to download from PHP’s download website for windows, but there is something you need to know before downloading any package, the download for a PHP version exists in 2 types — thread safe and non thread safe. Since you are using PHP with XAMPP, you are going to download the non-thread safe version because there is an apache file it has that would be used to configure XAMPP with PHP. After locating it, download the zip file. If you are running on a 32-bit system, download the non-thread safe version labelled with x86.

STEP 2

Apache file for XAMPP configuration

After you have downloaded it, extract the zip file and rename the extracted folder to «php», open the folder to find the apache file i mentioned in step 1 as shown in the image below. Once you have seen it, move the php folder to your xampp folder. Remember to make sure the current php folder in the XAMPP folder is either removed or renamed to something else so that the name won’t conflict with the one you are moving.

STEP 3

After moving the php folder into the XAMPP folder, open the folder and look for the php.ini config file. Whenever you download a PHP package, the php.ini file comes in two parts, php.ini-development and php.ini-production. These two config files represent the settings running on your development and production environments. Since you are using XAMPP, you would be using the development config file, so rename that config file to php.ini.

Читайте также:  Java array new size

STEP 4

Open your XAMPP control panel. Under the actions option for Apache, look for the config button, click on it and select the Apache (httpd-xampp.conf) config file to open it. This is the file that XAMPP uses to configure PHP properly, look for the following:

LoadFile "C:/xampp/php/php7ts.dll" LoadModule php7_module "C:/xampp/php/php7apache2_4.dll" 

NOTE — Search everywhere in the file for «php7_module» and change it to «php_module» as you might need to change it in some places.

STEP 5

After you have done all this, save the changes and restart your server, go back to this url and confirm that your PHP version has changed. if everything was done correctly, you should see that you have successfully changed your PHP version!

PHP version 8 image

Very easy and convenient. You can agree it is really not difficult to change your PHP version in XAMPP as it is quite simple to do. Connect with me on twitter and linkedin to find out more about me and my work.

Источник

Managing multiple PHP versions on Windows with Visual Studio

Author

by Miloslav Beno
April 12, 2021 8 minutes

Managing multiple PHP versions on Windows with Visual Studio

There are several reasons why to have multiple PHP installations locally. You might have one old project that requires PHP 5.6 (already end of line since January 1st 2019), the other project in PHP 7.1 and one more project in PHP 7.4 which you are upgrading to PHP 8.0.

Fortunately with PHP Tools for Visual Studio it’s quite easy to install and switch between PHP versions. The idea is to define requirements you have in the project and it’s up to the PHP Tools to fulfill those requirements.

Installing new PHP version

In the project properties, in the Application tab you can define what language level (version) you are interested in. Then run the project ( F5 ) PHP Tools will verify if there is an available environment that fulfills this requirement on your machine.

Install new PHP Version

If there is PHP runtime you want, like in my case, you will be prompted with the dialog asking you to let it install required products. Click to Continue and PHP will be installed.

Resolving issues.

Output during PHP installation

If you want be more specific about the environment you want to develop your project in, go to the Server tab. In this tab you can specific PHP runtime. Even though you’ve specified Language level in the Application tab, there might be more PHP installations that fits; you can select the one you want here.

Note Since 1.51.13160 x64bit PHP distributions are installed by default on 64bit Operating system.

In this configuration tab, you can also specify what server you want to use for development. Currently you can select from these servers: —PHP Build-in server As of PHP 5.4. there is build-in server in the PHP itself. In most cases it will be enough, but keep in mind there it’s just single-threaded web server, which doesn’t support .htaccess or any rewrite module out of the box. You can find more information at https://www.php.net/manual/en/features.commandline.webserver.php

  • IIS Express Lightweight, self-contained version of IIS optimized for developers. This should suffice for most of your developer needs. But if you plan to run the project on Apache in the production, use Custom server option.
  • IIS If you need full-featured IIS web server
  • Custom When you cannot select from previous options or you want to run/debug the project on remote server, this is the option.
Читайте также:  Java lang illegalstateexception chromedriver

Server tab

Configuring PHP

When PHP is installed by PHP Tools it has already been configured. But in case you’d like to change it you can find current php.ini file in the Project properties, Server tab.

Current php.ini in the Server tab

In case there is a known issue present in your configuration you will be notified when you run the project and you can let PHP Tools to fix those.

Issues with PHP Configuration

Updating PHP or Xdebug

Tech world is constantly evolving, every day there is a new update for something, new fix, improvement, or optimization… PHP is no different. When an update for PHP version defined for your project gets available, PHP Tools will notify. Following picture shows dialog that notified me when new Xdebug got available. Clicking Continue will install and configure it.

Updating Xdebug

This process will keep your current configuration intact. But in case of Xdebug it will transform the configuration when you are updating from Xdebug 2.x to 3.x since the configuration options has changed. If you would like to know more details there is an upgrade guide here https://xdebug.org/docs/upgrade_guide

Change to different PHP Version

If you need to switch your project to different PHP version, go to Server tab and select which Runtime you want to use. It can be already installed(e.g. you already have your own PHP installation) or it might be PHP version that’s not present and will be installed and configured by PHP Tools. Same can be done in the Application tab, Language Level, but I mostly do it here since I can exactly see which particular runtime and server it’s going to be used.

Btw. all these configurations are per-project, so it will not influence any other projects you have. Once you’ve switched to the new PHP version, PHP Tools might notify you there are some configuration issues that needs to be solved. Either click on the link in the yellow box and let PHP Tools solve them now, or it will be solved when you run the project. Up to you.

Issues to be solved

Since I’ve switched the project from PHP 8.0. to PHP 7.4. I get an error message that I use a syntax which is only supported since PHP 8.0. I can fix this now before finding it later when running the code (or I might never find out if I will not run this particular piece of code during runtime), which makes the transition easier.

Open Command Prompt

Sometimes it’s required to open up the command prompt from current folder and type those commands. In the Solution Explorer, right click on the project node, or any folder and select Open Command Prompt From Here... The command line will open with php set to the one you have active in your project.

Open Command Prompt From Here.

Command line

Conclusion

Managing multiple PHP version can be a pain, but it doesn’t have to be. We’ve tried to shape whole experience into the few clicks in the project properties. Please let us know if you find this helpful, or if there is something else we can look into.

Источник

Оцените статью