I'm trying to create a laravel project with composer and when I run
composer create-project laravel/laravel example-app
in the terminal, the process stops with the following error:
[RuntimeException]
php: does not exist and could not be created.
I have php 7.4 running through Wampserver and I've added it's PATH to the environment variables and when I run php -v in the terminal, everything seems fine:
PHP 7.4.0 (cli) (built: Nov 27 2019 10:14:18) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
what am I missing here? I'm using composer version 2.1.4 and running the command in administrative mode didn't make a difference neither.
screenshot of running commands on the command-line
Update to version 2.1.5 of Composer by running this command:
composer self-update
This was a bug that has since been fixed. It was attempting to create a directory called php: which is not possible on Windows systems.
Related
I've tried several attempts and the results are all unsuccessful.
composer says my php version is 7.3 but i am already installing php 8.0.2
I've seen some posts in the same situation as me, but it didn't solve anything at all.
this is my test server error code
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.23. in /home/vagrant/code/interproindigo/vendor/composer/platform_check.php on line 24
But when I run php -v, the php version is 8.0.9 as follows
PHP 8.0.9 (cli) (built: Jul 30 2021 13:03:39) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.9, Copyright (c) Zend Technologies with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
How can I solve this problem?
The problem occurred because the php version of the real server and the test server did not match.
php7.4 -f /usr/local/bin/composer update
Entering this code solved the problem.
I try to install Laravel 8 to vagrant. The install process works without problem. But the homepage shows the following error:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". You are running 7.2.34-8+ubuntu18.04.1+deb.sury.org+1. in /home/vagrant/code/7time/vendor/composer/platform_check.php on line 24
When I check the version, it shows 7.3
vagrant#homestead:~/code$ php -version
PHP 7.3.24-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 31 2020 16:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.24-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I tried these things:
I searched on Google for solution
I reinstalled PHP
I tried to install Laravel via Laravel installer and via Composer
What might be wrong?
Difference CLI / PHP-FPM
$ php -version gives the PHP CLI version, not the PHP-FPM version.
$ service php7.x-fpm status gives the php-fpm status/version.
CLI:
$ php artisan serve , Runs the application through your cli.
Homestead ( Vagrant box ):
Homestead ( Vagrant box ) is using NGINX by default. This means that the application will use PHP-FPM.
Duplicate of:
Change Laravel Homestead v7.0.1 with php 7.2 to php 7.1
How to roll back PHP version in Vagrant and Homestead?
I'm trying to install laravel 6 running the command:
composer create-project --prefer-dist laravel/laravel {appName}
But this command returns to me 5.8.* version:
Installing laravel/laravel (v5.8.35)
- Installing laravel/laravel (v5.8.35): Loading from cache ...
I'm using Wampserver 3.2. I've selected the 7.4.0 version, and I've tried to change CLI also (right click on tray icon > tools > php CLI version).
When I access the phpinfo.php on localhost, gives me the right version (7.4.0), but typing the command php -v, returns to me:
PHP 7.1.9 (cli) (built: Aug 30 2017 18:34:46) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
I'm posting this information, but I don't know if it really has anything to do with downloading version 5.8. *. Any sugestion?
Please update with command
composer update
compose upgrade
I've been having this issue for quite some time now. First of all, I have MAMP Pro Server installed on my Mac OS and the default PHP Version selected is 7.3.8. I have also checked the 'Make this version available on the command line' option. But whenever I try to run laravel tests using the phpunit command, I get the following error;
PHPUnit 8.4.3 by Sebastian Bergmann and contributors.
This version of PHPUnit is supported on PHP 7.2, PHP 7.3, and PHP 7.4.
You are using PHP 7.1.16 (/usr/bin/php).
I have confirmed my php version on available on the command line using php -v an it outputs
PHP 7.3.8 (cli) (built: Aug 14 2019 16:42:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
Please kindly help.
Your /usr/bin/php file does not link to your MAMPs version of php. This file is used by phpunit (in your case).
Let me tell you how you can switch it:
First of all, move away the original link
sudo mv /usr/bin/php /usr/bin/php.bak
Then link /usr/bin/php to your actual MAMP PHP version:
sudo ln -s /Applications/MAMP/bin/php/php7.3.8/bin /usr/bin/php
Validate it with /usr/bin/php -v giving you the 7.3.8 version.
When installing Drupal 8, just before database setup, I get a few errors and warnings, but I also see the following:
PHP
7.1.14-1+ubuntu16.04.1+deb.sury.org+1
However, doing php -v I get:
PHP 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 6 2018 16:11:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.2-3+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Clearly, my web server is running 7.2 but Drupal thinks it's 7.1. This is causing a problem where I have gd installed on PHP 7.2, but Drupal doesn't see gd installed on PHP 7.1 (because it isn't, at least its php.ini file doesn't have the gd extension enabled). Same with a few of the other errors and warnings.
How can I get Drupal 8 to recognize the correct PHP version?
So I figured it out:
Runing sudo a2dismod php7.1 then sudo a2enmod php7.2 seems to work perfectly (after a restart of Apache).
Try To install using composer
This method creates a project in web folder and other files outside web folder
composer create-project drupal-composer/drupal-project:8.x-dev d8_test_project --stability dev --no-interaction
Or
This method creates a project in a normal folder structure
composer create-project drupal/drupal my_site_name 8.*#dev --no-dev
I don't think it's about "recognizing" version, but you most likely have 2 different versions, one for console and other for web server. Run phpinfo() and see what PHP version is used by web server.