how shall I run a composer update command - php

I am trying to ask the question as precisely as possible but I myself have lots of confusion about this. So please bear with me
Problem - We have a third party API (Recurly) installed in our site. That site was built with Laravel. The version of that API is now outdated and I want to update the version via composer.
From the Recurly I have got the following instruction to upgrade the version
In composer.json file update the line of code from "recurly/recurly-client": "2.8." to "recurly/recurly-client": "2.12. . And this will upgrade your client library AND your API version.
Once you do this, please run a composer update in your terminal->active directory w/ Recurly and it will update you:
I have updated the line inside composer.json file. But I dont understand the second part of the instruction. How to run a composer update. Shall I update the composer itself? But I want to update the Recurly API version. is it necessary to update the composer itself?
I have found this link: https://getcomposer.org/doc/03-cli.md#update-u
In this link its written
In order to get the latest versions of the dependencies and to update the composer.lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.
php composer.phar update
I am not sure Is this the command I need?
Our webserver is with AWS. And we have WHM and cPanel installed to manage the web server.
I understand my question is not not precise as expected . but I cant figure out where to start actually. Please suggest me accordingly

As composer update command can create additional problem to the server hence i have run composer update only for Recurly as a root
composer update recurly/recurly-client
It is important to run the command from the directory where the composer.lock and composer.json files are
for an example if you have several sites under your server and if you run the command as root it may affect other sites as well.
To prevent that first you have to run
cd /home/websitefolder
then
composer update recurly/recurly-client
This way you can update only single package and it will not affect the rest of your site

There are two approaches to solving your problem,
Option A
as was stated, go to your composer.json and update the line
go to Terminal at the cpanel, should you not have terminal, use option 2
cd into your directory and run php composer update, (please before doing this, make sure to have a copy of your composer.json and the lock files.
Option B (No Terminal at cpanel)
Zip your directory and download
copy the file after unzipping to your wamp/xamp directory
edit the composer.json
and run php composer update (things can break here, I think the best is to run composer install rather than update)
zip and upload the file back.
I believe that should solve the problem

Related

composer install recognizing updated composer.json file

I am familiar with the concept that, when composer.lock file is present, composer install command runs the packages from this file.
So when I add (manually put a vendor/pkg list) to "require" in composer.json, and run command install then only those packages locked in composer.lock files get installed.
But this understanding of mine got conflicted, when I found composer.lock file being git-ignored by my senior developers.
When any update on composer.json file is pushed to deployment server, command install is being run and it seems to "install" the updated packages.
What got me confusing is, since there's no mention of that newly added package in the composer.lock file in the deployment server, how is it being installed?
I tried the same on my local:
first added vendor/pkg in require of composer.json.
tried running command install.
And got this warning instead:
warning: the lock file is not up to date with the latest changes....
nothing to install or update.
So my question is :
why two different behaviors are being shown?
How are the newly added packages in .json and not in .lock are being installed in the deployment server and not in local?
I have been researching on this for a while, and its bugging me.
Maybe I am getting it wrong. Anyone there to clear this out?
There are a few options:
Add vendors with composer require vendor/pkg
Add in composer.json as you did, but then run composer update vendor/pkg (Running composer update without the package name will update all of them)

Laravel Composer Update Changed Files

I need to discus a very important thing for me (probably for all users who uses composer in their projects). I am working on laravel. Whenever i work on my local machine, i run composer update after adding new library in vendor.
Now it works fine on local machine. But when i upload these files on my server, it shoots error like "Undefine class ....". I dont know how to run composer update command on server (Also it might be not safe).
So may i just know which files are updated by using composer update on cmd. What other files needed to go live to avoid this error??
You may:
Run composer update on your local server only, whenever you want.
Commit/push every files (including composer.lock) but the vendor directory
Deliver to your production server (without vendor, with composer.lock)
Then run composer install on your production server. It will update all your dependencies according to your composer.lock(so the exact same versions as your last update on your local server).
So in other words: you should not run composer update on your server, just composer install on every delivery (and you will need to keep your composer.lock)
Hope it will help you.
run composer dump-autoload before composer update. If still doesn't work then try to clear composer cache using composer clear-cache
composer update will update the version of every package from you vendor folder.
normally if you can not ensure you need update all the version of every package, you should use composer install
the reason of error "undefined class" is normally caused from app.php.Because service provider is defined in app.php, but the class(package) not been installed.
in order to solve your problem, try do this in three ways:
composer install --no-scripts;
comment the service providers which not been installed already from app.php, then composer install
composer dump-autoload

Problems installing laravel with composer [duplicate]

This question already has answers here:
How to place the ~/.composer/vendor/bin directory in your PATH?
(22 answers)
Closed 6 years ago.
Problem: I'm wanting to explore laravel 5, and failing miserably at installing it. I'm using this guide: http://laravel.com/docs/5.0 and need someone to help me understand the instructions.
Background and What I've Tried
I'm running Mac OSX 10.10.2 (Yosemite) and MAMP.
So far, I've downloaded Composer to my home folder using terminal. There is just a composer.phar file sitting there.
When I run:
composer global require "laravel/installer=~1.1"
I get the message:
Changed current directory to /Users/MYUSERNAME/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
I assume that is ok because when I run the following in terminal, I get the composer logo and a list of options
~ MYUSERNAME$ composer
I'm not 100% sure what the following means, from the Laravel Docs:
"Make sure to place the ~/.composer/vendor/bin directory in your PATH so the
laravel executable can be located by your system."
Because I can't figure it out, the following steps throw errors, such as:
-bash: laravel: command not found
I've been going through a few forums, and it's suggested that I need to update my PHP.ini file - this seems more related to Composer install, and not specifically Laravel. Because composer is working, this seems to be a dead end.
Ideally, I want to install Laravel 5 to the directory
HomeFolder/sites/test
because Composer.phar is in my home folder, I think the command should be:
php composer laravel new sites/test
or just
composer laravel new sites/test
As mentioned, it just (correctly) throws errors.
Question:
If anyone can help solve my total user error, by explaining what "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable can be located by your system." means to a n00b, that'd be really appreciated.
Many thanks!
Laravel is a PHP framework (makes writing PHP applications easy)
Composer is a PHP package and dependency manager. (makes installing and updating third party code libraries easy)
When you run
$ composer global require "laravel/installer=~1.1"
You're using composer to install the laravel/installer=~1.1 package into composer's "global" project folder (usually ~/.composer). This is what installed the command line program named laravel.
The command line program named laravel is a shell script for installing the PHP framework (Also named Laravel).
Your "Unix Path" is a list of folders where a command line script will search for an executable. Usually is has folders like /usr/bin, /usr/local/bin, etc. This is why when you run ls, you're actually running /usr/bin/ls -- the shell knows to check each folder in the path for a location. You can view your current path by typing
$ echo $PATH
So, the problem is composer installed the laravel command line program to a folder that's not in your unix path. You need to add this folder to your unix path. You can do this by running the following (assuming you're using bash, which is OS X's default shell)
$ PATH=$PATH:~/.composer/vendor/bin
If you run that, you should be able to run the laravel command line program and continue your installation.
Most people add this to their .bash_profile or .bashrc files. The Unix Stack Exchange has a lot of good information if you're interested in learning how to do this.
You can add the directory to the PATH variable by editing /etc/paths.
Here's a tutorial on how to do that.
Just add a line with:
~/.composer/vendor/bin
Then the laravel new command should work fine
If everything fails you can still use the composer create-project command to make a new laravel instance:
composer create-project laravel/laravel sites/test --prefer-dist
I added C:\Users\Leon\AppData\Roaming\Composer\vendor\bin instead of ~/.composer/vendor/bin to the Path variable.
Here is instructions on changing the path variable on Windows 10:
http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path

Composer Update Laravel

A developer has sent me his project to work with, but when ever I try to update or install my vendors everything works great until the very end and it outputs the message bellow.
C:\xampp\htdocs\BigWaveMedia\davinkit>php artisan migrate
{
"error": {
"type": "Exception",
"message": "expected color value: failed at `.clearfix;` C:\\xampp\\htdocs\\BigWaveMedia\\davinkit\\app\\start\/..\/..\/public\/less\/style.less on line 102",
"file": "C:\\xampp\\htdocs\\davinkit\\vendor\\leafo\\lessphp\\lessc.inc.php",
"line": 3258
}
}
C:\xampp\htdocs\BigWaveMedia\davinkit>
Any ideas at all? Here is a full log http://pastebin.com/y9q4Rc5z
When you run composer update, composer generates a file called composer.lock which lists all your packages and the currently installed versions. This allows you to later run composer install, which will install the packages listed in that file, recreating the environment that you were last using.
It appears from your log that some of the versions of packages that are listed in your composer.lock file are no longer available. Thus, when you run composer install, it complains and fails. This is usually no big deal - just run composer update and it will attempt to build a set of packages that work together and write a new composer.lock file.
However, you're running into a different problem. It appears that, in your composer.json file, the original developer has added some pre- or post- update actions that are failing, specifically a php artisan migrate command. This can be avoided by running the following: composer update --no-scripts
This will run the composer update but will skip over the scripts added to the file. You should be able to successfully run the update this way.
However, this does not solve the problem long-term. There are two problems:
A migration is for database changes, not random stuff like compiling assets. Go through the migrations and remove that code from there.
Assets should not be compiled each time you run composer update. Remove that step from the composer.json file.
From what I've read, best practice seems to be compiling assets on an as-needed basis during development (ie. when you're making changes to your LESS files - ideally using a tool like gulp.js) and before deployment.
The following works for me:
composer update --no-scripts
this is command for composer update please try this...
composer self-update
write this command in your terminal :
composer update
You can use :
composer self-update --2
To update to 2.0.8 version (Latest stable version)

What if I don't want to do composer update, I just want to use what ever in composer.json and composer.lock

I have an old composer based symfony project, that I just updated with some changes of code. I tested in development everything works fine. I have got issue when deploying the composer asked to run composer.phar self-update to update the composer since the composer is outdated. After that I do the composer.phar install. I get this error -
[RuntimeException]
Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.
What if I don't want to update. I am okay this. How can I force it not to update.
The structure of the lock file was changed, and therefor you should upgrade your lock file. You can upgrade your lock file without actually upgrading any dependencies by executing:
composer update nothing
I would suggest you look at the composer.lock file and note any versions that are used there. Then copy these into the composer.json, delete the lock file and run a normal install.
Of course, you do this on a copy of your software to see if all the same versions do appear again.

Categories