Use Laravel vendor dependency inside your app with composer.
Besides, the Laravel framework which come with composer.json
, each RVsitebuilder app can contains its own composer.json
. So you can specify your own vendor dependency and get export to the server separately.
/packages/vendor-name/project-name/
├── composer.json
Make sure that you run composer
command on RVsitebuilder root directory, not inside your app.
Here is an example of filemanager app's composer.json
:
{
"name": "rvsitebuilder/filemanager",
"description": "This filemanager package",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Rvsitebuilder\Filemanager\": "src/"
}
},
"extra": {
"component": "package",
"laravel": {
"providers": ["Rvsitebuilder\Filemanager\FilemanagerServiceProvider"],
"dont-discover": ["alexusmai/laravel-file-manager"]
},
"rvsitebuilder": {
"require": {
"php-function": ["json_decode", "file_put_contents"],
"php-ini": {
"max_execution_time": "30",
"memory_limit": "64M"
}
}
}
}
}
You can adding the function name in the php-function
section on your app’s composer.json
file.
You can adding extension setting in the php-ini
section on your app’s composer.json
file.
Vendor that comes with view and route, may not display nicely in RVsitebuilder layout and may have security risk if you leave it accessible. You can disable Laravel vendor discovery by adding the vendor name in the dont-discover
section on your app’s composer.json
file.
"extra": {
"laravel": {
"dont-discover": [
"alexusmai/laravel-file-manager"
]
}
},
If you do this, you may need to copy code from vendor’s service provider to run loadMigrationsFrom
, mergeConfigFrom
, loadViewsFrom
, loadTranslationsFrom
, and etc. on your app's service provider
yourself. Be notice that register and boot on service provider are different. Do not mix it.
{warning} Wildcard
*
character inside of your app'sdont-discover
directive is not supported.
In case you disable vendor's service provider
, you will need to copy vendor's public resources
to app and publishes
on your app's service provider
.
In case you disable vendor's service provider
, you will need to copy vendor's migrations
to your app and call loadMigrationsFrom
on your app's service provider
.
public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
}
Once your app's service provider
have been registered, they will automatically be run when the php artisan migrate command is executed. You do not need to export them to the application's main database/migrations
directory.
If you rely on other composer projects and want to overwrite its configuration, just copy vendor's config
to your config folder and run mergeConfigFrom
from your app's service provider
.
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/vendor.php', 'vendor-name');
}
MergeConfigFrom
function only merges the first level of the configuration array. If you have a complex configuration, use config()
helper to overwrite it individually. Here is an example:
public function register()
{
config('totem.artisan.whitelist', true);
config('totem.artisan.command_filter', ['*:cache', 'queue:work', 'medialibrary:*']);
}
If you run Laravel vendor inside your app and also want to custom vendor's view without to override the vendor controller that call view command, you need to create vendor
directory and register your custom vendor's view directory to view.path
config.
Your app's custom vendor directory
:
/packages/vendor-name/project-name/
├── resources
│ └── views
│ ├── admin
│ ├── user
│ └── vendor
Your app's service provider
:
public function register()
{
$collection = collect($this->app['config']['view']['paths']);
$collection->prepend(__DIR__.'/../resources/views');
$this->app['config']->set('view.paths', $collection->toArray());
}
Noted that view.path
is the directory that contains vendor directory. Above example is correct. It does not have vendor after /resources/views.