I want to use the Mailgun service in Laravel 5. This requires Guzzle 5 to be installed. I've added the following to composer.json, and installed it:
"guzzlehttp/guzzle": "~5.0"
However, my app is giving me this error:
FatalErrorException in MailgunTransport.php line 121:
Class 'GuzzleHttp\Client' not found
I've ran composer dump-autoload. What am I missing? Thanks.
I solve this by using:
"laravel/framework": "5.0.16",
"guzzlehttp/guzzle": "5.2",
composer update
and that is all.
composer install installs the packages (including exact versions) listed in composer.lock. When adding a new package or changing the version requirements, you need composer update (or you can use composer require) as the new package isn't in the lock file yet.
Running composer install when the composer.json has been updated since the last update/require should generate a warning saying 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.
Related
This question already has answers here:
Composer: how can I install another dependency without updating old ones?
(5 answers)
Closed 2 years ago.
I want to install zizaco/entrust package in laravel 5.8, in their github page it was said to include "zizaco/entrust": "5.2.x-dev" in composer.json file and run composer update command. I did so as below and ran composer update command.
"require" : {
"php" : "^7.1.3",
"fideloper/proxy" : "^4.0",
"laravel/framework" : "5.8.*",
"laravel/tinker" : "^1.0",
"laravel/ui" : "^1.2",
"maatwebsite/excel" : "^3.1",
"zizaco/entrust" : "5.2.x-dev"
},
but composer update command updates all packages to latest versions (these packages i included in "require" field as above) when installing zizaco/entrust package. So is if there are some coding faults in latest updated packages then whole site can break. FYI after i run the above command i see local git showing changes in many files in folders under vendor folder, it means that there are some updates in packages right?. so it's recommended that composer install command should be run so that those dependency packages will not be updated to latest versions.
So, in my case after including "zizaco/entrust": "5.2.x-dev" in require field in composer.json as above, if i run composer install then it don't install zizaco/entrust package. Furthermore, if i run composer require zizaco/entrust 5.2.x-dev then it still installs latest versions of dependency packages.
So how do i prevent installing latest versions of dependency packages i included in "require" field in composer.json file and i only install zizaco/entrust package.
So that my laravel 5.8 site don't break for updating any packages to latest versions because of malfunction codes or whatever in latest versions. It's very important to handle this scenario because we need to install packages in laravel site for various needs.
You've got two options: use composer require to specify the package to install, or manually update your composer.json file and use composer update [package].
Composer Require
composer require zizaco/entrust:5.2.x-dev
This will automatically update your composer.json file and install the specified version. This will not update any of your other dependencies. While the documentation specifies the package and version should be separated by a colon (:), I tested it with a space and it seemed to work.
Composer Update [package]
composer update zizaco/entrust
If you have manually updated your composer.json file, you will need to run composer update and specify the package to update. If you specify a package to update, only that package will be affected. When you don't specify the package to update, composer will look for updates for all packages.
A Note On Composer Install
composer install will not help you here. If you already have a composer.lock file (which you will since you're just attempting to add a new package), composer install will only look at your composer.lock file and attempt to install everything that is defined there. That means, if you manually update your composer.json file, and run composer install, it will not install the new requirement you specified.
Only when you don't already have a composer.lock file will composer install attempt to resolve dependencies and install them.
Run composer install instead. Alternatively you could use composer require <package name>.
Composer install looks in your composer.lock for exact versions, and only in composer.json for packages that are missing.
Composer update will look in composer.json for version constraint which roughly means "a range of versions". This is why different versions are getting installed.
Step 1:
You just need to add your package to the composer.json file and run the command:
composer install
composer install will check for the new package and install that, besides that it will check for any deprecation in other packages.
Step 2:
You can directly run your command in composer
composer require package/name
For example, if I need to install firebase, run below command from the project root:
composer require firebase/php-jwt
Installing new packages from the terminal automatically adds it into the composer.json file and it does not update previously installed packages.
Hope this helps!!
I want to install riazxrazor/payumoney for laravel 5.8 but when I try to install composer require riazxrazor/payumoney it gives me an error:
enter image description here
This package isn't compatible with Laravel 5.8.
The Composer error message says symfony/http-foundation is the problem. This can happen when two projects--Laravel, and this Composer package--require different versions of the same library.
Laravel 5.8's Illuminate\Http requires:
"symfony/http-foundation": "^4.2",
riazXrazor/payumoey requires:
"symfony/http-foundation": "~2.6|~3.0"
The package would need to be updated to support newer versions of Laravel.
For this package(riazxrazor/payumoney), you just have to run this command at your command prompt
composer require riazxrazor/payumoney
After, you need to add this line in the provider section.
Open the config/app.php:
Riazxrazor\Payumoney\PayumoneyServiceProvider::class,
add this line in the aliases section:
'Payumoney' => Riazxrazor\Payumoney\PayumoneyFacade::class
Also, you have to fulfill the requirement of this package riazxrazor/payumoney
requires
php: >=5.5.0
symfony/options-resolver: ~2.6|~3.0
symfony/http-foundation: ~2.6|~3.0
My composer.json entry under "require" has this line:
"league/uri-parser": "^1.4",
Links to the package:
packagist.org
github.com
I get an exception that the following class is missing: League\Uri\UriString
I also found that v1.4.0 is not the latest version.
Things I've tried to update to the latest version
composer remove league/uri-parser followed by composer require league/uri-parser. It doesn't change anything
composer update. no change
vendor/bin/composer dump-autoload -o. No change.
composer clearcache and composer upgrade while the library was set to * and ^1.4 but terminal kept reporting "nothing to install or update"
Anyone know how to fix this?
The class is named League\Uri\Parser\UriString in the current release (v1.4.1) of league/uri-parser.
The \Parser\ part was removed only on the master branch but the latest release (v1.4.1) still uses the old namespace! ( See the commit )
Use the correct class (League\Uri\Parser\UriString) and your issue will be resolved.
recently I've started one project and want to use elasticsearch. But when I want to install guzzle for PHP via composer, I get folowing error. I have no idea what is this error.
My composer required packages are:
"require":{
"yiisoft/yii":"1.1.14",
"2amigos/yiiwheels":"1.0.3",
"clevertech/yii-booster": "4.0.1",
"drmabuse/yii-bootstrap-3-module": "dev-master",
"guzzle/guzzle": "3.9.0",
"elasticsearch/elasticsearch": "1.2.2"
},
my PHP Version 5.4.7
my composer.json file
I had no problem installing all the packages from your requirements in one go.
If the problem persists, try to delete the vendor folder and the composer.lock file and run composer update again.
I'm updating my app from Symfony2.0 to Symfony2.1.
When I run composer install I receive a fatal exception about JMS/SerializerBundle not being found when it reaches the generating autoload files step. I think cache:clear is causing this.
I've added it to composer.json:
"jms/serializer-bundle": "dev-master",
And in my appKernel:
new JMS\SerializerBundle\JMSSerializerBundle($this),
I basically followed the steps.
I also can not find the file in the vendor directory. The composer stated 'Nothing to install or update' though. It does not matter if I put in a version number. Think this is the same for the stof doctrine extension.
How do I resolve this?
Setting symfony to 2.1.0 allowed me to install the extra repositories.