composer php version error after uploading project to live server - php

Hello i'm trying to run my laravel project on live server using shared hosting after i upload all project file and directory and open my domain address it gives me error
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.8".
and yes i was set up the php version on composer.json as "php": "^8.1.8", and "php": "^8.1.8" on composer.lock and when i run the project in local machine it's running as expected without any error. i also check my php version on my shared hosting by using php -v and it's return:
PHP 8.1.8 (cli) (built: Jul 14 2022 13:17:16) (NTS)
Copyright (c) The PHP Group
and on my local machine using php -v it return:
PHP 8.1.8 (cli) (built: Jul 5 2022 23:04:29) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.8, Copyright (c) Zend Technologies
i'm already find similar problem but none help to solve this...

Thanks to suggestion from #TeachMe and #ErDiablo, i finally know way to encounter this errors, first the composer installed on the project will need to regenerate using composer install
but since i'm using shared hosting so i using composer install --no-scripts insteed because the limitation to access the direcetory from hosting providers and after using that commands, continue with type:
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
php artisan cache:clear
php artisan view:clear
php artisan package:discover
This will help to generate key, package, .env file, and clear cache.
after using all that commands, open your domain and everything should be done.
Notes:
if still got the same error it can be possible caused by the php selector that provided by cPanel i once get this error, it seems that the composer was confused to get php version (maybe that the shared hosting have multi php version installed) or host / domain was loaded the different php version with that provided from php -v so you will need to make your domain to use php version selector that provided by cpanel and make sure your domains not using multiPHP Manager and also make sure that the php version from php version selector point to the same version on composer.json (if you not using cpanel, you will need to find way to change the version via termial or ssh)

Related

Should I install additional php when XAMPP has default php package in it?

I'm a begginer in Laravel and I installed XAMPP as local server. I noticed that my XAMPP already install php 7.4 as it's dependency. But when I tried php -v in www dir in php it shown.
'php' is not recognized as an internal or external command, operable
program or batch file.
But in php directory is shown
PHP 7.4.15 (cli) (built: Feb 2 2021 20:47:45) ( ZTS Visual C++ 2017
x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c)
Zend Technologies
So, should I install additional php in my system for development? Should the version of the php matche with XAMPP php 7.4?
php -v will only tell you if you have PHP installed as a command line interface (PHP-CLI) which would enable you to run php code in cmd.exe or powershell. You'd normally not need this, but for reference here's how to enable it: https://stackoverflow.com/a/10753133 (mind the comment on Windows 10).
To check if PHP runs in your webserver environment (which is by default available in xampp), create a file test.php in your www folder with the following content:
<?php
phpinfo();
?>
Call this file in a browser, you will get an overview of all php features available. Delete the file before you go productive, because it will also give hackers a lot of information (which you don't want).
Try to add XAMPP PHP to Environment Variables
here is an instructions for Windows 10

Centos 7 php guzzle

I am at my wits end:
In my PLESK panel PHP is set to 7.2
In the CLI the output of php -v is: PHP 7.1.26 (cli)(built: Jan 11 2019 11:47:41)( NTS )
but when I run: composer require guzzlehttp/guzzle
This is the error
guzzlehttp/promises v1.3.1 requires php >=5.5.0 -> your PHP version (5.4.45) does not satisfy that requirement.
I even when as far as removing all other PHP version in PLESK
You say that you can change the PHP Settings in PLESK, that is commonly an example of a Multi PHP webserver.
That is very popular these days, but also there is something dangerous about it. When the website may run fine on it. The real problems is that there are two seperate PHP installations
The most legit situation is that your hosting provider installed Composer on PHP 5.4.45 and added PHP 7.+ after it.
Result: Composer will only work with PHP 5
You can see it as two seperate executable files (just for example, this is not the exact situation)
PHP 5: /usr/bin/php
PHP 7: /usr/bin/php7
There is one thing you can do right know. Do to the fact that PHP5 is the main PHP installation, I advise you to ask your hosting provider to reinstall Composer on PHP7
Note: Removing a PHP version in Plesk does not removes it also on the Operating System.

installing composer on a shared host

I am trying to install composer on my shared host for the first time.
When I run curl -sS https://getcomposer.org/installer | php
I am getting a Composer successfully installed
User it: php composer.phar
when I run php composer.phar i am getting this warring error:
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
any ideas on how to fix this ? and why i am getting this error ? :(
when I run php -v i get this back
PHP 5.4.39 (cgi-fcgi) (built: Mar 25 2015 14:20:20)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies
Do I need to run this using CLI version if so how would i do this ?
Any help would be nice thank you.
I resolved this by explicitly calling the version of PHP it asked for. Keep in mind that on a shared server environment there is often multiple versions of PHP running and even though you may have set up your default in your cPanel config, bash commands often resolve to another (lower) version.
First, I created a bin directory and moved composer.phar into it. Then, I added this alias to my .bash_profile and it worked like a charm:
alias composer="/usr/php/54/usr/bin/php-cli ~/bin/composer.phar"
Hope this helps!
As Composer is now available via WHM you can use this to find it:
which composer
This returned path "/opt/cpanel/composer/bin/composer" for me. If this returns nothing then disregard the rest of this answer, as Composer is not available to you at system level.
You can now use php-cli to call this with Composer's absolute path:
php-cli /opt/cpanel/composer/bin/composer install
php-cli /opt/cpanel/composer/bin/composer update
php-cli /opt/cpanel/composer/bin/composer require whatever/example
You may however need to alias php-cli if your system claims this isn't found. It very much depends how PHP has been deployed on the WHM server. You can do this by adding a user alias to the end of your ".bashrc" file as follows:
alias php-cli=/opt/cpanel/ea-php72/root/usr/bin/php
Replace ea-php72 with the release of PHP you want to use. Submit this as a command in the shell to make it available immediately, otherwise it'll become available when you open your next Bash session.
If you want to make this available with just composer alone you could create this alias again in ".bashrc":
alias composer=/opt/cpanel/ea-php72/root/usr/bin/php /opt/cpanel/composer/bin/composer
Or
php-cli $(which composer) ...
The location of the php versions installed will vary from host to host. Try finding them with:
locate /bin/php
For me this lists all php versions and I can then replace php with, for example:
/usr/bin/php71-cli
To access the command line interface version rather than the default cgi one. Then as stated by #Diggery you can create an alias.
alias composer='/usr/bin/php71-cli bin/composer.phar'
There are many suggestions on StackOverflow on how to test for a cli installation but the above is the only one that worked for me.
I have made a script to handle changes in composer/vendor. The script works with ftp-only servers, sends/removes only the changed files. Maybe someone will find it useful.
https://github.com/psad73/tune-composer

Installing laravel using Zend Server 8.0.1 PHP 5.6.4 CLI stopped working

I have Installed Zend Server 8.0.1 with PHP 5.6.4 on Windows 8.1. I have added 'E:\Program Files (x86)\Zend\ZendServer\bin' to PATH variable, which contains PHP binaries.
I have Installed Composer Globally. I am trying to create a Laravel project using composer command 'composer create-project laravel/laravel'. After a while PHP CLI stops working. Screen shot is below.
screen shot of PHP settings given below.
I tried it few times but same error. Has anybody faced same problem. Unfortunately I don't have tool to analyze Dump.
It is a bug with Zend Server 8.x, PHP 5.6 and composer running on Windows that Zend is aware of (see http://forums.zend.com/viewtopic.php?f=8&p=245953).
Using older version of composer.phar works for me. Get the composer.phar from the Zend Skeleton Application (https://github.com/zendframework/ZendSkeletonApplication) and try with it.

Laravel 4 - Error while running `composer install`

The problem:
I have installed Composer and followed the Quick start guide in the Laravel 4 documentation.
I get the following error when I run composer install or composer update:
Script php artisan optimize handling the post-install-cmd event
returned with an error...
I tried to run the following composer command:
composer create-project laravel/laravel myproject --prefer-dist
Or use their laravel.phar:
laravel new myproject
Or get the zip version from git: https://github.com/laravel/laravel?source=c
And I still fail to update via composer.
Additional information:
My PHP version on my Mac is:
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0,
Copyright (c) 1998-2013 Zend Technologies
PHP version on MAMP: 5.4.10
I found some solutions on Google / Stack Overflow but those did not work well in my case.
It says:
MCrypt PHP extension required
So it looks like you're missing the Mcrypt extension, which is required by Laravel (actually, I think it's used only by the Authentication class for password handling, not for the rest of the components of the framework).
I haven't got a Mac, but the command to install it should be something like this, using Homebrew
brew tap josegonzalez/php
brew install mcrypt php54-mcrypt
These links might help you:
http://www.jorble.com/2013/04/install-php-mcrypt-in-macosx/
http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/
Having the setting xdebug.scream = 1 in the configuration was the cause of the problem for me. I fixed it by doing the following:
Find XDebug configuration file.
$ sudo find / -name xdebug.ini
Edit file using any text editor.
$ sudo vi /your_path/xdebug.ini
Set xdebug.scream = 0
Reload the server (Apache/Nginx/whatever).
$ sudo service nginx reload
You might have Mcrypt installed already on your computer, if you are using MAMP or any other application. So, you don't need to install Mcrypt again. Add the following code to a php file and place it in your htdocs directory. See the info about the PHP you are running. You can see whether Mcrypt is already installed or not.
<?php
phpinfo();
If it shows Mcript, then do the following:
Check which PHP version you are using. You can see different directories for different PHP versions in this directory: /Applications/MAMP/bin/php/.
Move to the user's home directory. Use this command on terminal: cd ~.
Edit (or create a new one if not exists) .bash_profile file.
Add the following line:
where php5.5.10 is the directory of the PHP version you are using.
export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH
Now restart your computer. And you can use php artisan command of Laravel.
Source of information: Laravel requires the Mcrypt PHP extension

Categories