composer init
基礎信息配置illuminate/support
(提供ServiceProvidor
支持)自行組織,沒有特殊要求php
$this->mergeConfigFrom(__DIR__.'.../xxx.php', 'xxx');
# boot方法中註冊 if ($this->app->runningInConsole()) { $this->commands([ XxxCommand::class, ... ]); }
$this->loadRoutesFrom(__DIR__.'.../routes.php');
$this->loadViewsFrom(__DIR__.'.../views', 包名);
或發佈文件resources/views/vendor/包名
return view('包名::視圖名')
$this->loadMigrationsFrom(__DIR__.'.../migrations');
或發佈文件$this->loadTranslationsFrom(__DIR__.'.../translations', 包名);
或發佈文件echo trans('courier::filename.strname');
php artisan vendor:publish [--tag=發佈組標識] --forcelaravel
#boot方法中註冊待發布文件 $this->publishes( [ $from => $to __DIR__.'.../xxx.php' => config_path('xxx.php'), //配置文件 __DIR__.'.../migrations' => database_path('migrations'), //遷移文件 __DIR__.'.../views' => resource_path('views/vendor'), //視圖文件 __DIR__.'.../translations' => resource_path('lang/vendor'), //翻譯文件 ], [可選的發佈組標識] );
Illuminate\Support\ServiceProvider
config/app.php
-> $providors
裝載composer.json
-> extra
節區配置包發現從而自動裝載"extra": { "laravel": { "providers": [ //包裝載 "Xxx\\YyyServiceProvider" ], "aliases": { //Facade裝載 "Zzz": "Xxx\\ZzzFacade" }, "dont-discover": [ //禁止裝載 "Mmm/Nnn", "*" ] } }