访问地址 https://laravel-workerman.iwnweb.com/
https://github.com/mouyong/laravel-octane-workerman/tree/gatewayworker/webman_plugin_require_example
在项目的 composer.json
添加如下内容。可参考 laravel-octane-workerman
的 composer.json
中,scripts
配置
{
// ...
"scripts": {
"post-package-install": [
"JieAnthony\\LaravelOctaneWorkerman\\WebmanPlugin::install"
],
"post-package-update": [
"JieAnthony\\LaravelOctaneWorkerman\\WebmanPlugin::install"
],
"pre-package-uninstall": [
"JieAnthony\\LaravelOctaneWorkerman\\WebmanPlugin::uninstall"
],
// ...
}
// ...
}
composer require webman/push -vvv
- 修改插件的
route.php
文件 - 将
Webman\Request
替换为Illuminate\Http\Request
- 将
Webman\Route
替换为Illuminate\Routing\Router
- 使用 laravel 的路由分组包含路由
- 替换
Route::
调用为$route->
示例:
// use support\Request;
// use Webman\Route;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
app('router')->middleware(['web'])->group(function (Router $route) {
/**
* 推送js客户端文件
*/
// here before
// Route::any('plugin/webman/push/push.js', function (Request $request) {
// return response()->file(base_path() . '/vendor/webman/push/src/push.js');
// });
// here after
$route->any('plugin/webman/push/push.js', function (Request $request) {
return response()->file(base_path() . '/vendor/webman/push/src/push.js');
});
});
- 手动执行
composer dump-autoload
,让项目自动自行@php artisan package:discover --ansi
命令
composer du # 简写