Hello Friends I am new in Laravel framework.
i create modules directory in app folder.
then i also create ServiceProvider.php file in modules directory.
I'm pretty newbie in creating a package. The first time after I created the following structure, I put it in Vendor folder.
qplot
environment-color
src
config
QPlot
EnvironmentColor
ColorServiceProvider.php
EnvironmentColor.php
tests
But soon I realized this doesn't make sense, since Laravel won't autoload all the bundles for you unless you registered it. So I moved folder to /app/vendor (new folder).
And then following Andreyco's suggestion to notify autoload path
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/vendor",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
And then when I run php artisan dump-autoload
, and open vendor/composer/autoload_classmap.php
, all new classes under QPlot are registered :)
Now when I go back to add the provider to Laravel /app/config/app.php
,
'providers' => array(
'QPlot\EnvironmentColor\ColorServiceProvider'
So the steps are
Add this to composer.json
autoload section:
"psr-4": {
"App\\": "app/"
}
and then composer dump-autoload