Composer update PHP warning -- related to new package? (Laravel4) - php

I just added a new package to my composer.json in Laravel4 --
"barryvdh/laravel-dompdf": "0.4.*"
and on doing command line "composer update", I got this warning:
PHP Warning: Unexpected character in input: ' in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php on line 118
which I've never seen before on all previous Composer updates, which have all been flawless. In fact, the exact same message appeared 6 times, so I'm assuming that this reflects multiple attempts by Composer.
Here's my "require" array in composer.json:
"require": {
"laravel/framework": "4.2.*",
"barryvdh/laravel-dompdf": "0.4.*"
},
Am I correct in assuming that this relates to bad code in the package I've added, and not something on my end? The only change I made was to add the package to my composer.json file, and that's clearly not what the error message refers to. Thanks.

Take the package out of your composer file, and then do:
composer update
Then, add a different package, if you need an example: use Jefferey Way's laravel generator:
"way/generators": "2.*"
which every laravel install should have. if it runs through correctly, post an issue on the conflicted packages github about the error.
I apologize that i cant give you an exact answer, but unit testing the conflicting package is outside the scope of the question

Related

UnexpectedValueException Could not parse version constraint when trying to instal laravelcollective

I am new to laravel and I am trying to install laravelcollective. I am just following to documentation here and I am using this from my project directory:
composer require "laravelcollective/html":"^5.4.0"
Unfortunately, immediately after I press ented I get the following error :
[UnexpectedValueException]
Could not parse version constraint :5.4.0: Invalid version string ":5.4.0"
I just don't know how to troubleshoot this. I didn't find much on google and this combined with my lack of experience with laravel leaves me stuck.
Can someone help?
You can add it manually in composer.json then use composer update.
Just add "laravelcollective/html": "5.4.*", under the row with "laravel/framework":"5.4.*",
Like this :
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.4.*",
"laravelcollective/html": "5.4.*", <-- Add this row
"laravel/tinker": "~1.0"
},
You should never run composer update without any arguments if you do not want to update all your dependencies.
In your case, the issue probably is that the ^ character is already interpreted by your shell before the argument is passed to Composer. This could possibly be solved by using single quotes instead of double quotes:
composer require 'laravelcollective/html:^5.4.0'
When you used the 5.4.* constraint as suggested in one of the comments above, you added a space after the colon which leads to Composer interpreting the version constraint as a package name. The right command would have been this:
composer require "laravelcollective/html":"5.4.*"
composer require "laravelcollective/html ^5.4.0"
Worked for me!
In my case, I was using Laravel 5.7 and kept getting an error when trying to install the Laravel collective.
You can use this command without specifying any version:
composer require 'laravelcollective/html'
It worked for me. :)

Missing 'Illuminate\Routing\ControllerServiceProvider' class on Laravel 5.2

I have updated the composer.json file as instructed on the upgrade guide on Laravel 5.2 Documentation and run composer update.
Everything was updated correctly, but composer dumped the error below while generating autoload files.
Class 'Illuminate\Routing\ControllerService Provider' not found in /home/vagrant/Code/homework/vendor/laravel/framework /src/Illuminate/Foundation/ProviderRepository.php on line 146
Make sure you remove Illuminate\Routing\ControllerServiceProvider from your /config/app.php.
https://www.laravel.com/docs/5.2/upgrade (see the "Service Providers" section)
Problem is with your composer.json.It may got corrupted. Make sure
"require": {
"laravel/framework": "5.2.*"
},
exists.Then run composer update.

Composer Laravel Class 'yajra\Datatables\DatatablesServiceProvider' not found

I have a problem with laravel and composer package yajra/laravel-datatables
Here is my require part from composer.json:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"cartalyst/sentinel": "^2.0",
"laravelcollective/html": "^5.2",
"yajra/laravel-datatables-oracle": "^6.1"
},
After executing composer update all passes fine and I can check that inside vendor dir has appeared yajra folder.
After that I have add new provider in app.php:
yajra\Datatables\DatatablesServiceProvider::class
and then run php artisan but followingerror appears in the console:
Class 'yajra\Datatables\DatatablesServiceProvider' not found
I can fix this error by editing autoload_classmap.php file and manually add
'yajra\\Datatables\\DatatablesServiceProvider' => $vendorDir . '/yajra/laravel-datatables-oracle/src/DatatablesServiceProvider.php',
Anyway, the next time I execute composer update this line is deleted and again appears the same error and I again have to manually edit autoload_classmap.php file.
There is something wrong which causes composer update to not update relevant autoload files. I can not get it what is going on.
You should use in your app.php
Yajra\Datatables\DatatablesServiceProvider::class
instead of
yajra\Datatables\DatatablesServiceProvider::class
(with capital letter)
Try removing syntactic sugar operators like tilde and caret sign in composer.json. Because sometimes they do not allow the exact version to install. The same problem happened to me also. Then run,
comoposer update
Solved the issue for me.

Adding Guzzle For Mailgun in Laravel 5

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.

Loading a composer package into Laravel 5

Solved: I've added the php and illuminate/support packages into my package composer.json file and it started working. I've got no idea why though so if someone could explain, I would really appreciate it.
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
},
I've created a composer package for Laravel 5 which should generate models based on an existing database schema. However i'm unable to load it in.
I add my Command class into the app/Console/Kernel.php
'Iber\Generator\Commands\MakeModelsCommand'
But then I get the following error:
Class Iber\Generator\Commands\MakeModelsCommand does not exist
I'm really new to Laravel and I'm not sure why this is happening since composer generates the autoloader file just fine. I've created and added (into config/app.php) a Service Provider but that doesn't get resolved either. Not sure what I'm doing wrong.
Here's the package:
https://github.com/ignasbernotas/laravel-model-generator
Apparently adding the required attribute with the following packages solved the issue. I'm still not sure why.
"require": {
"php": ">=5.4.0",
"illuminate/support": "~5.0"
},

Categories