Reputation: 79
So I am using laravel 5.3 and I have just created my first bare package for a CMS that I have created. It works fine however I don't want to be adding the to composer.json autoload manually i want this to be done automatically from a drag and drop or a select option in the admin area eg:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Corium\\MediaManager\\" : "packages/corium/mediaManager/src"
}
},
Then I want this: Corium\MediaManager\MediaManagerServiceProvider::class,
added to the config/app.php provider array with out the end user needing to enter the backend code. What is the best way of doing this because i cant work out how to get this to work.
Thank you
Upvotes: 3
Views: 2573
Reputation: 5673
Registering services with the application should almost always be done within a service provider. Service providers, as you know, are registered in config/app.php
, so you will have to manually register at least one provider. However, within that provider, you have access to an app
property that is an application instance, which you can call the register
method on to register additional providers. This way you can have one provider pre-registered and register additional providers as you need them in code.
The documentation on Writing Service Providers should get you started.
Upvotes: 2