I am using Site5 which allows multiple php. So I tried to run composer install and it welcomed me with various version related errors. Laravel 5.3 needs 5.6+ and I have 5.5 installed but my hosting allows various version including PHP7. PHP7 is installed as /usr/local/php70/bin/php
Now how can I make composer and artisan to use these commands. Specially composer
Related
Lately l've been working with Laravel. I use composer to install packages and artisan for commands.
The problem is that my machine uses Laravel 5.4 not 5.7.
When i run phpinfo() the result is PHP Version 7.2.7. Do you think that the problem is that i don't use the latest version of xampp which it has included php 7?
Based on comment, yes it is related to PHP version. Your PHP CLI version is too low to support newer version of laravel. You need to update or switch PHP CLI to newer version. Server and CLI PHP are separate packages and might have different versions.
No it is not related to PHP version (in this case).
Probably you ran
composer install
which will install dependencies in versions defined in composer.lock to update dependencies run
composer update
For differences between install and update you can refer to this question
From the comments:
laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.19) does not satisfy that requirement.
Run php -i in the Terminal. Looks like your webserver and your command line (which Composer uses) are using different versions of PHP.
Laravel version depends on your installation way. It's not related to your PHP or XAMPP version. And you are using the latest PHP version, so don't worry about PHP version.
Read the Laravel installation to install the latest version of laravel.
If you using package laravel/installer
Update this package
composer global update
and try to run
laravel new my-app
I have two projects running php7.0 and 5.6. Now the default version of php cli is 7.0. I need to run composer-update on project 5.6 but the composer is reading php7.0 so it will throw an error since there are features that only compatible in 5.6. Is there a way to tell composer which version to use during composer-install and composer-update without changing the default php-cli?
Yes, you just have to specify which PHP version to use by directly calling the intended PHP bin file.
So, instead of
php composer.phar update
You have to use something like
/path/to/php5.6/bin/php composer.phar update
In my case, on a CentOS server with Plesk (default PHP version was 5.4, but I also had 5.6 and 7.0 installed), I had to use :
/opt/plesk/php/5.6/bin/php composer.phar update
I ran into a troublesome issue.
I'm using 1 and 1 virtual private server redhat linux. The server's default PHP version is PHP 5.3.
I do have installed PHP 5.5 on the server. I switch to PHP 5.5 using alias php='path to php'.
I run command php -v to see if the version has changed, indeed it has - the PHP version is now 5.5.
However I am still unable to install phalcon, when I run the command ./install -i I get this error message:
Php 5.3 is not supported.
Any ideas how to resolve this problem?
Alias will not work in your case because it changes php path only for your terminal, not globally.
I'm not a redhat user so can't give you exact steps but a kinda dirty solution is to find your php binary (on debian is in /usr/bin/, /bin/ or /usr/local/bin), rename it to for example php5.3 and in this place make a symbolic link to new php.
Remember that your php webserver (apache, nginx or whatever you use) should also have an updated php! What is more, to compile phalcon you'll need also an updated phpize and other dependencies. I'm not a linux expert so cannot tell you exactly which parts of php5-dev did changed between PHP 5.3 and 5.5 and which did not.
Alternatively you can just clone from github and install an old phalcon 2.x which is also great. The new 3.0 doesn't have that much breaking features. It's killing feature is PHP7 which it seems that you're not going to use. Phalcon 2.x requires PHP5.4+
I belive there are better ways how a php update should be performed but I don't know them.
I created a webapplication using Laravel 5.1 and PHP v. 5.6. However, I need to clone this into a CentOS server which has PHP v. 5.4.16 installed.
Whenever I run composer install, I get the following error:
Warning: The lock file is not up to date with the latest changes in
composer.json. You may be getting outdated dependencies. Run update to
update them. Your requirements could not be resolved to an installable
set of packages.
Followed by packages that require PHP >= 5.5.9.
Is there a workaround to make this application work without updating PHP?
Thanks in advance!
You cannot install Laravel 5.1 on a server running PHP 5.4. You really have 2 options:
Try upgrading PHP
Migrate your application to Laravel 5.0
Migrating should not be that much work, especially if you have tests setup for your application. There will be some features in your 5.1 app that you may lose and have to work around to migrate to 5.0, but overall, it shouldn't be too difficult.
I have a Vagrant machine with the actual PHP version I want my server to run on, but locally I use a newer version of PHP.
Updating Composer locally just saves so much time as opposed to updating it on the virtual machine via SSH.
So my question is: Does it affect the vendor files when composer install or update is called from different versions of PHP?
The PHP version used when updating the dependencies affects the packages being used. Packages can define a requirement on a certain PHP version.
A common requirement found is requiring PHP 5.4 or 5.5 when a package is using the features of said versions, or PHP 5.3.3 or PHP 5.3.27 because the package needs certain bugfixes.
Composer will complain about not being able to execute composer install if the PHP version used when running this command is not able to fulfill all PHP version requirements that are mentioned in the lock file.
Running composer update with an older PHP version than composer install probably will work in most cases. Using the same PHP version should be the recommended setting, though.
Also: Using the same required extensions in all PHP versions also is needed for requirements checking.
Note that there is some demand for Composer to assume a given PHP version or extension is present on the target platform even if the command line PHP running the Composer command does not fulfill them, but this feature is not implemented yet. So there is no way to override the local PHP version with the one present on the target environment.