I created a package for Laravel 4 that worked properly when used in development in workbench but when I install it with Composer it keeps returning me the error Class 'Myvendor\Mypackage\MypackageServiceProvider' not found
.
There is a particularity with my package which is that the name of my classes sources are different from the name of my package. Usually they are the same.
vendor/
Houle/
laravel-dynamite/
src/
Fhoule/
Dynamite/
DynamiteServiceProvider.php
I know that it can work because Laravel work's this way too.
vendor/
laravel/
framework/
src/
Illuminate/
And the property PSR-0 of my package composer.json seems to be properly configured:
"name": "Houle/laravel-dynamite",
...
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.0.x"
},
"autoload": {
"classmap": [
"src/migrations",
"src/controllers",
"src/models"
],
"psr-0": {
"Fhoule\\Dynamite": "src/"
}
},
...
How I created my package:
- Created the package with Artisan.
- Maked it work properly in workbench directory
- Pushed to private Bitbucket repo
- Installed new instance of Laravel
Changed composer.json configuration to install my package (from private repository)
"name": "laravel/laravel", ... "require": { "laravel/framework": "4.0.*", "Houle/laravel-dynamite": "2.0.1" }, "repositories": [{ "type": "package", "package": { "name": "Houle/laravel-dynamite", "version": "2.0.1", "source": { "url": "[email protected]:Houle/laravel-dynamite.git", "type": "git", "reference": "v2.0.1" } } }], ...
Added my package Service Provider to app/config/app.php:
'providers' => array( 'Fhoule\Dynamite\DynamiteServiceProvider', )
That's where my application return the error Class 'Fhoule\Dynamite\DynamiteServiceProvider' not found
.
What could be my issue?
php artisan dump-autoload
? – Hao Luocomposer install
orupdate
, but yes I tried it. – FR6