mouyong/webman-laravel

dev-master
版本
2022-11-22
版本更新時(shí)間
51
安裝
11
star
簡(jiǎn)介
webman 內(nèi)的 laravel,不會(huì)產(chǎn)生 Facade 問(wèn)題,自動(dòng)注冊(cè)服務(wù)提供者,可按 laravel 規(guī)范進(jìn)行研發(fā),可引入 laravel 擴(kuò)展包
安裝
- 在
start.php
中強(qiáng)制優(yōu)先加載本地的./support/helpers.php
。使用webman/console
時(shí),需要對(duì)./webman
可執(zhí)行文件同樣做如下更改,優(yōu)先加載./support/helpers.php
。
#!/usr/bin/env php
<?php
// 避免加載了 laravel/illuminate/foundation/helper.php 導(dǎo)致無(wú)法控制順序的函數(shù)重定義報(bào)錯(cuò)
require_once __DIR__ . '/support/helpers.php'; // <- here.
require_once __DIR__ . '/vendor/autoload.php';
support\App::run();
- 移除
composer.json
中autoload.files
的./support/helpers.php
文件加載
{
...
"autoload": {
"psr-4": {
...
"": "./",
"App\\": "./app"
},
"files": [] // <- here.
},
...
}
- 安裝插件
composer require mouyong/webman-laravel:dev-master
配置項(xiàng)目
在 config/app.php 中增加如下內(nèi)容
return [
...
'name' => 'webman',
'env' => 'development',
'providers' => array_filter(array_map(function ($item) {
if (class_exists($item)) {
return $item;
}
}, [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/**
* 你安裝的 laravel 擴(kuò)展包
*/
// \Fresns\PluginManager\Providers\PluginServiceProvider::class,
/**
* 項(xiàng)目的擴(kuò)展包
*/
\App\Providers\AppServiceProvider::class,
])),
'aliases' => \Illuminate\Support\Facades\Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class,
])->toArray(),
];
更新 composer.json
composer.json
"scripts": {
// 初始化 laravel-zero/illuminate 與相關(guān)配置
"post-autoload-dump": [
"MouYong\\WebmanLaravel \\ComposerScripts::postAutoloadDump"
],
...
}
增加 Http 啟動(dòng)引導(dǎo)
config/bootstrap.php
return [
\MouYong\WebmanLaravel\LaravelBootstrap::class,
...
];
使用
php artisan
composer require illuminate/auth # 參考 `laravel` 官方配置 `config` 目錄,增加相關(guān)的配置項(xiàng):https://github.com/laravel/laravel