Composer Vendor and App Dependency

Use Laravel vendor dependency inside your app with composer.

Composer Vendor Dependency

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"
        }
      }
    }
  }
}

php-function

You can adding the function name in the php-function section on your app’s composer.json file.

php-ini

You can adding extension setting in the php-ini section on your app’s composer.json file.

Disable Vendor Service Provider Auto Discovery

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's dont-discover directive is not supported.

Publishing Vendor Asset

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.

Define Migrate for Vendor

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.

Overwrite Vendor Configuration

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:*']);
}

Custom Vendor View Directory

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.