mouyong/webman-laravel
dev-master
版本
2022-11-22
版本更新时间
50
安装
11
star
简介
webman 内的 laravel,不会产生 Facade 问题,自动注册服务提供者,可按 laravel 规范进行研发,可引入 laravel 扩展包
安装
- 在
start.php
中强制优先加载本地的./support/helpers.php
。使用webman/console
时,需要对./webman
可执行文件同样做如下更改,优先加载./support/helpers.php
。
#!/usr/bin/env php
<?php
// 避免加载了 laravel/illuminate/foundation/helper.php 导致无法控制顺序的函数重定义报错
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
配置项目
在 config/app.php 中增加如下内容
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 扩展包
*/
// \Fresns\PluginManager\Providers\PluginServiceProvider::class,
/**
* 项目的扩展包
*/
\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 与相关配置
"post-autoload-dump": [
"MouYong\\WebmanLaravel \\ComposerScripts::postAutoloadDump"
],
...
}
增加 Http 启动引导
config/bootstrap.php
return [
\MouYong\WebmanLaravel\LaravelBootstrap::class,
...
];
使用
php artisan
composer require illuminate/auth # 参考 `laravel` 官方配置 `config` 目录,增加相关的配置项:https://github.com/laravel/laravel