Reputation: 8371
I have create a simple Laravel Package and pushed it on Github
https://github.com/akshaykhale1992/model-notes
and Published the Package on Packagist
https://packagist.org/packages/akshaykhale1992/model-note
I tried to install it in my laravel application, it pulled the package from Github but the package installation was not successful.
Below is the Error that is returned by composer command
[email protected]:~/$ composer require akshaykhale1992/model-note
Using version dev-master for akshaykhale1992/model-note
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing akshaykhale1992/model-note (dev-master 5543914): Cloning 554391487e from cache
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
In ProviderRepository.php line 208:
Class 'AkshayKhale1992\ModelNote\ModelNoteProvider' not found
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Thanks in advance.
Upvotes: 0
Views: 8401
Reputation: 40663
In order for composer to properly generate the autoload file for your package (as well as all packages) it needs to know where to find the namespaces and files that are referenced. This is done via the autoload
entry in composer.json
In your case, since you are already following the PSR-4 standard you need something like:
"autoload": {
"psr-4": {
"AkshayKhale1992\\ModelNote\\": "src/"
}
}
Upvotes: 1