Reputation: 12549
I was developing with a repo that worked fine in Laravel. When I forked the repo, I now get this error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'DevIT\Hasoffers\Laravel\Providers\HasoffersServiceProvider' not found
I tried commenting out the provider line in app.php
, then ran these, and afterward uncommented the line but these didn't help:
composer dump-autoload
php artisan clear-compiled
php artisan optimize
Here is the config for that in composer.json:
"require": {
"devit/hasoffers-php-client": "dev-master",
"devit/hasoffers-laravel-client": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"name": "devit/hasoffers-php-client",
"version": "dev-master",
"source": {
"url": "https://github.com/ecomevo/hasoffers-php.git",
"type": "git",
"reference": "master"
}
}
},
{
"type": "package",
"package": {
"name": "devit/hasoffers-laravel-client",
"version": "dev-master",
"source": {
"url": "https://github.com/ecomevo/hasoffers-laravel.git",
"type": "git",
"reference": "master"
}
}
}
],
If I navigate to the vendor dir, the package is there and composer claims it brought it in during latest update.
What have I gotten wrong here?
Upvotes: 1
Views: 319
Reputation: 62238
Your composer file is using package
repositories, which will not read the composer.json
file of the packages being pulled in. Since the PSR-4 autoloading is defined in those composer.json
files, it is not being setup, and your class is not being found.
You could add the autoload functionality to your packages definition, but your best bet would be to use the vcs
repository type, so that their composer.json
files will be respected.
Your composer file should look something like:
"require": {
"devit/hasoffers-php-client": "dev-master",
"devit/hasoffers-laravel-client": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ecomevo/hasoffers-php"
},
{
"type": "vcs",
"url": "https://github.com/ecomevo/hasoffers-laravel"
}
],
Since you have already pulled these packages in with a previous method, you may need to clear your composer cache before doing a composer update:
composer clearcache
composer update devit/hasoffers-php-client
composer update devit/hasoffers-laravel-client
Upvotes: 2