Plugin is a Laravel package which was created to manage your large Laravel app using modules. A plugin is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 9.
Creating a plugin is simple and straightforward. Run the following command to create a plugin.
php artisan plugin:make author/plugin-name
plugins/
|-- plugin-name/
|-- src/
|-- database/
|-- factories/
|-- migrations/
|-- seeders/
|-- Http/
|-- Controllers/
|-- Middleware/
|-- Requests/
|-- Datatables/
|-- Models/
|-- Providers/
|-- PluginNameServiceProvider.php
|-- resources/
|-- assets/
|-- js/
|-- app.js
|-- sass/
|-- app.scss
|-- lang/
|-- views/
|-- routes/
|-- api.php
|-- admin.php
|-- tests/
|-- composer.json
|-- package.json
|-- webpack.mix.js
Open the composer.json file, you will see a file of the form
{
"name": "author/name",
"description": "Description plugin.",
"extra": {
"juzaweb": {
"providers": [
"Author\\Name\\Providers\\PluginNameServiceProvider"
],
"name": "Plugin Display Name",
"domain": "domain",
"cms_min": "3.0",
"version": "1.0"
}
},
"autoload": {
"psr-4": {
"Author\\Name\\": "src/"
}
}
}
Extra juzaweb config
When you create a new module it also registers new custom namespace for Lang, View and Config. For example, if you create a new module named blog, it will also register new namespace/hint blog for that module. Then, you can use that namespace for calling Lang, View or Config. Following are some examples of its usage: Calling Lang:
Lang::get('domain::group.name');
On blade template
@trans('domain::group.name');
Calling View:
view('domain::index')
view('domain::folder.index')