laravel/framework v6.9.0 requires php ^7.2 - php

I just finish my laravel project on my local machine, I want to upload to my server to become live api, okay, I searched, youtubed, googled, or etc.. and found some solution for upload, I just upload my whole project, without vendor, and composer.lock, not set database config yet. after upload, I run:
composer install
it give me some error about php version:
Problem 1
- laravel/framework v6.9.0 requires php ^7.2 -> your PHP version (7.1.33) overridden by "config.platform.php" version (5.5.9) does not
satisfy that requirement.
But my php version is:
PHP Version 7.3.13
How can I fix this?

Check your .bash_profile on ~ root and add this lines:
PATH="/usr/local/php73/bin:$PATH" // make sure your path to php73
export PATH
then:
php -v -> reboot -> php -v

Related

Old Laravel project is not working after a while, What can I do to make it running again?

I have an old project and I am not the person that worked on it
I need to run it again but it's giving me this error
This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
I tried to run composer update but it gives me this error
Problem 1
- Root composer.json requires php ^7.1.3 but your php version (8.1.5) does not satisfy that requirement.
Problem 2
- laravel/framework[v5.6.0, ..., 5.6.x-dev] require php ^7.1.3 -> your php version (8.1.5) does not satisfy that requirement.
- Root composer.json requires laravel/framework 5.6.* -> satisfiable by laravel/framework[v5.6.0, ..., 5.6.x-dev].
You can do composer install by following command
composer install --ignore-platform-reqs --no-script
Also another way can be to update your composer.json php version to 8 or downgrade your system php version to php7.
Hope it works.

Running 2 Symfony projects with different php versions

I'm working on a Symfony (4.4) project with PHP version(7.1.30) and now I want to start a new Symfony (5.0/5.1) project.
But I could not do it because it wants at least PHP 7.2.5. (Windows 10 machine).
I have installed PHP 7.3.6 and added it to the PATH environment. But when I try to create the new Symfony project I get this error:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- symfony/symfony v5.0.2 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement.
- symfony/symfony v5.0.1 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement.
- symfony/symfony v5.0.0 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement.
- Installation request for symfony/symfony ^5.0 -> satisfiable by symfony/symfony[v5.0.0, v5.0.1, v5.0.2].
Can you please advise how can I use 2 different PHP versions for the different projects?
(I can't upgrade the 'old' project because some extensions cannot work with 7.2.5)
To run composer with an older php version, download an appropriate phar of composer for that version. The latest is probably compatible with all versions, but if it doesn't work download an earlier version until it starts working.
Then run the non default php with the following command in the composer.phar directory(replace C:\php7.2.5 with your actual path):
C:\php7.2.5\php.exe -c C:\php7.2.5\php.ini composer.phar update
If you use git bash(what I do)
/c/php7.2.5/php.exe -c /c/php7.2.5/php.ini composer.phar update
You can also make this into a batch or bat file pretty easy.
The -c flag is to point to the correct php.ini.
You can select the php version for the project with
echo 7.4.10 > .php-version
When you create the .php-version for each project you can run the server as you run it usually and everything works fine
Also, when I use 7.4.10 locally, I have to use my commands like this
symfony php bin/console make:migration
with symfony before php bin/console

Latest Laravel and latest WAMP issues

I have them both vanilla setup. Laravel setups up fine. But when i run composer install i get;
> Problem 1
- This package requires php ^7.1.3 but your PHP version (7.0.11) does not satisfy that requirement.
Problem 2
- Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].
- doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.11) does not satisfy that requirement.
Problem 3
....
Problem 24
- Installation request for sebastian/diff 3.0.1 -> satisfiable by sebastian/diff[3.0.1].
- sebastian/diff 3.0.1 requires php ^7.1 -> your PHP version (7.0.11) does not satisfy that requirement.
Problem 25
- laravel/framework v5.6.26 requires php ^7.1.3 -> your PHP version (7.0.11) does not satisfy that requirement.
- laravel/tinker v1.0.7 requires illuminate/console ~5.1 -> satisfiable by laravel/framework[v5.6.26].
- Installation request for laravel/tinker v1.0.7 -> satisfiable by laravel/tinker[v1.0.7].
A total of 25 problems when running composer on laravel...
I have understood so much my php version differs in minor version, but what can i do to fix it?
Thanks!
I think your laravel version wants php version >= 7.1.3 but your installed version is 7.0.11.
If you have installed latest laravel version i.e(5.6) then it should match following requirements:
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
Please check laravel installation guide https://laravel.com/docs/5.6/installation#installation
Yea, there where mismatches in version. Strangley enough i downloaded another phpversion 7.2.xx. And it almost worked like a charm. They have some strange things going on eg. the extensions config directive s never prefixed with "php_" in the ini file and it is very easy to miss, so you will need to add it yourswelf also there are no extension dir config by default, you also need that one. Its commented out, another workhour to find this this.
Thanks for your reply!

Laravel 5.5. and PHP 7

I am updating to Laravel 5.5. which uses PHP 7.0 version. I need to do setup on my local machine and on AWS as well. First, locally WAMP server is installed which comes with PHP 7.0 ... I've selected it and when localhost is opened I get the message that the PHP version is 7.0.10 ... After changing version numbers for Laravel and PHP in composer.json, I did update and got this message:
Problem 1
This package requires php >=7.0 but your PHP version (5.6.25) does not satisfy that requirement. Problem 2
laravel/framework v5.5.2 requires php >=7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
laravel/framework v5.5.1 requires php >=7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
laravel/framework v5.5.0 requires php >=7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
Installation request for laravel/framework 5.5.* -> satisfiable by laravel/framework[v5.5.0, v5.5.1, v5.5.2].
It is written that I still use 5.6. How can I change this?
According to #iainn Apache is using PHP 7, but the CLI (which Composer uses) is still using 5.6 hence, trying to uninstall and install composer again and select the correct php version (7.0) while setup. Check below screenshot
You're getting an error from composer. Try using
'composer install --ignore-platform-reqs'
to setup your project folder.
Just change varible enviroment on your computer
add path php you would you like to use

How to push Laravel 5.4 project to a server with PHP CLI version 5.4.16?

My client uses a server with Apache PHP version 5.6.30 but the CLI PHP version is 5.4.16. And they can't change the CLI PHP version.
I use Git && SSH to push the project to the server from my local machine. But since the CLI PHP version is 5.4.16, I can't run
composer install
I will get these messages
Problem 1
- This package requires php >=5.6.4 but your PHP version (5.4.16) does not satisfy that requirement.
Problem 2
- symfony/var-dumper v3.3.2 requires php >=5.5.9 -> your PHP version (5.4.16) does not satisfy that requirement.
- symfony/var-dumper v3.3.2 requires php >=5.5.9 -> your PHP version (5.4.16) does not satisfy that requirement.
- Installation request for symfony/var-dumper v3.3.2 -> satisfiable by symfony/var-dumper[v3.3.2].
The phpinfo() tells that the version of PHP is 5.6.30. So I guess that part should be fine. But I don't know that to solve this situation.
When I go to the website, I get these error messages:
Warning: require(/var/www/vhosts/example.com/httpdocs/vendor/composer/ClassLoader.php): failed to open stream: No such file or directory in /var/www/vhosts/example.com/httpdocs/vendor/composer/autoload_real.php on line 12
Warning: require(/var/www/vhosts/example.com/httpdocs/vendor/composer/ClassLoader.php): failed to open stream: No such file or directory in /var/www/vhosts/example.com/httpdocs/vendor/composer/autoload_real.php on line 12
Fatal error: require(): Failed opening required '/var/www/vhosts/example.com/httpdocs/vendor/composer/ClassLoader.php' (include_path='.:/opt/plesk/php/5.6/share/pear') in /var/www/vhosts/example.com/httpdocs/vendor/composer/autoload_real.php on line 12
Since you're using plesk, you should find the binary of other PHP versions at /opt/plesk/php.
/opt/plesk/php/5.6/bin/php /usr/bin/composer install
Although not ideal, you can also push the entire vendor folder along to the server. All composer install really does is create the vendor folder. If you upload your entire project folder, vendors included, then you will be able to run it on the server without running composer. As long as the web version meets your minimum requirements, then this means that you should be able to effectively ignore the client version.
That being said, you'll run into this problem again if you need to run any tasks from the command line.

Categories