Plugin Artisan
Overview
php artisan fresns // Enter Plugin Development Mode
fresns plugin // View All Commands
fresns plugin:list // View All Installed Plugins
fresns new // Generate A New Plugin
fresns enter // Go to plugin directory
fresns back // Back to the fresns root directory
// Development
fresns make:command // Generate Plugin Command
fresns make:migration // Generate Plugin Migration
fresns make:seed // Generate Plugin Seed
fresns make:factory // Generate Plugin Factory
fresns make:provider // Generate Plugin Provider
fresns make:controller // Generate Plugin Controller
fresns make:model // Generate Plugin Model
fresns make:middleware // Generate Plugin Middleware
fresns make:dto // Generate Plugin DTO (fresns/dto)
fresns make:mail // Generate Plugin Mail
fresns make:notification // Generate Plugin Notification
fresns make:listener // Generate Plugin Listener
fresns make:request // Generate Plugin Request
fresns make:event // Generate Plugin Event
fresns make:job // Generate Plugin Job
fresns make:policy // Generate Plugin Policy
fresns make:rule // Generate Plugin Rule
fresns make:resource // Generate Plugin Resource
fresns make:test // Generate Plugin Test
fresns make:schedule-provider // Generate Plugin Schedule Provider
fresns make:event-provider // Generate Plugin Event Provider
fresns make:sql-provider // Generate Plugin SQL Provider
fresns make:cmdword-provider // Generate Plugin Command Word Provider (fresns/cmd-word-manager)
// Control
fresns plugin:unzip // Unzip the plugin package to the plugin directory: /extensions/plugins/{fskey}/
fresns plugin:publish // Publish Plugin (static resources): /public/assets/plugins/{fskey}/
fresns plugin:unpublish // Unpublish (remove static resources)
fresns plugin:composer-update // Update Plugin Composer Package
fresns plugin:migrate // Run Plugin Migrate
fresns plugin:migrate-rollback // Rollback Plugin Migrate
fresns plugin:migrate-refresh // Refresh Plugin Migrate
fresns plugin:migrate-reset // Reset Plugin Migrate
fresns plugin:seed // Run Plugin Seed
fresns plugin:install // Install Plugin (Run the unzip/publish/composer-update/migrate command in sequence)
fresns plugin:uninstall // Uninstall Plugin
// Management
fresns plugin:activate // Activate Plugin
fresns plugin:deactivate // Deactivate Plugin
Plugin control and management commands are also supported in the Artisan way.
// Artisan Control
php artisan plugin:unzip // Unzip the plugin package to the plugin directory: /extensions/plugins/{fskey}/
php artisan plugin:publish // Publish Plugin (static resources): /public/assets/plugins/{fskey}/
php artisan plugin:unpublish // Unpublish (remove static resources)
php artisan plugin:composer-update // Update Plugin Composer Package
php artisan plugin:migrate // Run Plugin Migrate
php artisan plugin:migrate-rollback // Rollback Plugin Migrate
php artisan plugin:migrate-refresh // Refresh Plugin Migrate
php artisan plugin:migrate-reset // Reset Plugin Migrate
php artisan plugin:seed // Run Plugin Seed
php artisan plugin:install // Install Plugin (Run the unzip/publish/composer-update/migrate command in sequence)
php artisan plugin:uninstall // Uninstall Plugin
// Artisan Management
php artisan plugin:activate // Activate Plugin
php artisan plugin:deactivate // Deactivate Plugin
Command Usage Flow
When using plug-in instructions, you need to enable the development mode first, then enter the plug-in directory, and directly use the instructions in the plug-in directory.
- Enable development mode
php artisan fresns
- Introduce the project path (auto-identify, just enter)
export /path/to/project/vendor/bin
- Go to the plugin directory
fresns new DemoPlugin // Create a plugin called DemoPlugin
fresns enter DemoPlugin // Go to the plugin DemoPlugin directory
fresns back // Back to the fresns root directory
- Execute development, management, and control commands in the plugin directory
Generate
Generate a new plugin.
fresns plugin:make DemoPlugin
# or
fresns new DemoPlugin
Development
Generate Plugin Command
Generate the given console command for the specified plugin.
fresns make:command CreateDemoCommand
Generate Plugin Migration
Generate a migration for specified plugin.
fresns make:migration create_demos_table
Generate Plugin Seed
Generate the given seed name for the specified plugin.
fresns make:seed seed_fake_demos
Generate Plugin Factory
Generate the given database factory for the specified plugin.
fresns make:factory FactoryName
Generate Plugin Provider
Generate the given service provider name for the specified plugin.
fresns make:provider DemoServiceProvider
Generate Plugin Controller
Generate a controller for the specified plugin.
fresns make:controller PostsController
Generate Plugin Model
Generate the given model for the specified plugin.
fresns make:model Post
Optional options:
--fillable=field1,field2
: set the fillable fields on the generated model--migration
,-m
: create the migration file for the given model
Generate Plugin Middleware
Generate the given middleware name for the specified plugin.
fresns make:middleware CanReadPostsMiddleware
Generate Plugin DTO
Generate a DTO(data transfer object) for specified plugin.
fresns make:dto VerifySignDTO
Generate Plugin Mail
Generate the given mail class for the specified plugin.
fresns make:mail SendWeeklyPostsEmail
Generate Plugin Notification
Generate the given notification class name for the specified plugin.
fresns make:notification NotificationAdminOfNewComment
Generate Plugin Listener
Generate the given listener for the specified plugin. Optionally you can specify which event class it should listen to. It also accepts a --queued
flag allowed queued event listeners.
fresns make:listener NotificationUsersOfANewPost
fresns make:listener NotificationUsersOfANewPost --event=PostWasCreated
fresns make:listener NotificationUsersOfANewPost --event=PostWasCreated --queued
Generate Plugin Request
Generate the given request for the specified plugin.
fresns make:request CreatePostRequest
Generate Plugin Event
Generate the given event for the specified plugin.
fresns make:event BlogPostWasUpdated
Generate Plugin Job
Generate the given job for the specified plugin.
fresns make:job JobName
//A synchronous job class
fresns make:job JobName --sync
Generate Plugin Policy
Generate the given policy class for the specified plugin.
The Policies
is not generated by default when creating a new plugin. Change the value of paths.generator.policies
in plugins.php
to your desired location.
fresns make:policy PolicyName
Generate Plugin Rule
Generate the given validation rule class for the specified plugin.
The Rules
folder is not generated by default when creating a new plugin. Change the value of paths.generator.rules
in plugins.php
to your desired location.
fresns make:rule ValidationRule
Generate Plugin Resource
Generate the given resource class for the specified plugin. It can have an optional --collection argument to generate a resource collection.
The Transformers
folder is not generated by default when creating a new plugin. Change the value of paths.generator.resource
in plugins.php
to your desired location.
fresns make:resource PostResource
fresns make:resource PostResource --collection
Generate Plugin Test
Generate the given test class for the specified plugin.
fresns make:test EloquentPostRepositoryTest
Generate Plugin Schedule Provider
Generate a console service provider for specified plugin.
fresns make:console-provider
Generate Plugin Event Provider
Generate a event provider for specified plugin.
fresns make:event-provider
- You need to add it yourself to the
providers
parameter ofplugin.json
.
Generate Plugin SQL Provider
Generate a sql provider for specified plugin.
fresns make:sql-provider
- You need to add it yourself to the
providers
parameter ofplugin.json
.
Generate Plugin Command Word Provider
Generate a cmd word service provider for specified plugin.
fresns make:cmdword-provider
- You need to add it yourself to the
providers
parameter ofplugin.json
.
Control
Unzip The Plugin Package
Unzip the plugin files into the /plugins/
directory, the final directory will be /plugins/{fskey}/
.
fresns plugin:unzip /www/wwwroot/fresns/storage/plugins/123e4567-e89b-12d3-a456-426614174000.zip
// or
php artisan plugin:unzip /www/wwwroot/fresns/storage/plugins/123e4567-e89b-12d3-a456-426614174000.zip
Publish Plugin
Publish static resources for the plugin DemoPlugin
.
fresns plugin:publish
// or
php artisan plugin:publish DemoPlugin
/plugins/DemoPlugin/Resources/assets/
Distribute to web directories/public/assets/plugins/DemoPlugin/
Unpublish
Unpublish static resources for the plugin DemoPlugin
.
fresns plugin:unpublish
// or
php artisan plugin:unpublish DemoPlugin
/plugins/DemoPlugin/Resources/assets/
Distribute to web directories/public/assets/plugins/DemoPlugin/
Update Plugin Composer Package
Composer all plugins.
fresns plugin:composer-update
// or
php artisan plugin:composer-update
Run Plugin Migrate
Migrate the given plugin, or without a plugin an argument, migrate all plugins.
fresns plugin:migrate
// or
php artisan plugin:migrate DemoPlugin
Rollback Plugin Migrate
Rollback the given plugin, or without an argument, rollback all plugins.
fresns plugin:migrate-rollback
// or
php artisan plugin:migrate-rollback DemoPlugin
Refresh Plugin Migrate
Refresh the migration for the given plugin, or without a specified plugin refresh all plugins migrations.
fresns plugin:migrate-refresh
// or
php artisan plugin:migrate-refresh DemoPlugin
Reset Plugin Migrate
Reset the migration for the given plugin, or without a specified plugin reset all plugins migrations.
fresns plugin:migrate-reset
// or
php artisan plugin:migrate-reset DemoPlugin
Run Plugin Seed
Seed the given plugin, or without an argument, seed all plugins.
fresns plugin:seed
// or
php artisan plugin:seed DemoPlugin
Install Plugin
Execute the plugin:unzip
、plugin:composer-update
、plugin:migrate
、plugin:publish
commands in that order.
fresns plugin:install /www/wwwroot/fresns/storage/plugins/123e4567-e89b-12d3-a456-426614174000.zip
// or
php artisan plugin:install /www/wwwroot/fresns/storage/plugins/123e4567-e89b-12d3-a456-426614174000.zip
Uninstall Plugin
Uninstall the plugin and select whether you want to clean the data of the plugin.
fresns plugin:uninstall --cleardata=true
fresns plugin:uninstall --cleardata=false
// or
php artisan plugin:uninstall DemoPlugin --cleardata=true
php artisan plugin:uninstall DemoPlugin --cleardata=false
/plugins/DemoPlugin/
Physically deletion the folder./public/assets/plugins/DemoPlugin/
Physically deletion the folder.- Remove the plugin composer dependency package (skip if the main application or another plugin is in use)
- Logically deletion the value of the record where the
fskey
column of theplugins
table isDemoPlugin
.
Management
Activate Plugin
fresns plugin:activate
// or
php artisan plugin:activate DemoPlugin
Deactivate Plugin
fresns plugin:deactivate
// or
php artisan plugin:deactivate DemoPlugin