mouyong/webman-laravel

Webman plugin mouyong/webman-laravel

dev-master 2022-11-22 00:57 UTC

This package is auto-updated.

Last update: 2024-11-22 05:32:39 UTC


README

  1. 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();
  1. 移除 composer.jsonautoload.files./support/helpers.php 文件加载
{
    ...
    "autoload": {
        "psr-4": {
            ...
            "": "./",
            "App\\": "./app"
        },
        "files": [] // <- here.
    },
    ...
}
  1. 安装插件
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

效果截图

image

image