webman-tech / polyfill
Webman plugin webmantech/polyfill
Installs: 2 062
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
Requires (Dev)
- illuminate/http: ^v9.30
- illuminate/validation: ^9.30
- symfony/http-foundation: ^6.1
- webman-tech/laravel-filesystem: ^2.1
- webman-tech/laravel-validation: ^1.1
- workerman/webman-framework: ^1.4
README
webman 是基于 php-cli 的框架,这区别于传统的 php-fpm 框架,因此部分功能存在区别(比如 Http Request 信息的获取)
但是 packagist(composer 包)中有大部分的扩展是基于 symfony/http-foundation
的,如果不能使用的话会产生很多不便
因此本扩展的目标是使得 webman 下能快速使用如 SymfonyRequest 等类
安装
composer require webman-tech/polyfill
版本说明
由于 symfony>6 的版本使用 php8,且加强了类型返回,与 <6 版本的方法无法兼容,因此该包也必须做拆分
Symfony
composer require symfony/http-foundation
namespace app\controller; use support\Request; use WebmanTech\Polyfill\SymfonyRequest; use WebmanTech\Polyfill\SymfonyUploadedFile; class FooController { public function bar(Request $request) { $symfonyRequest = SymfonyRequest::wrapper($request); // $symfonyRequest 此时所有功能同 `Symfony\Component\HttpFoundation\Request` $symfonyUploadedFile = SymfonyUploadedFile::wrapper($request->file('file')); // $symfonyUploadedFile 此时所有功能同 `Symfony\Component\HttpFoundation\File\UploadedFile` } }
Laravel
composer require illuminate/http
namespace app\controller; use support\Request; use WebmanTech\Polyfill\LaravelRequest; use WebmanTech\Polyfill\LaravelUploadedFile; class FooController { public function bar(Request $request) { $laravelRequest = LaravelRequest::wrapper($request); // $laravelRequest 此时所有功能同 `Illuminate\Http\Request` $laravelUploadedFile = LaravelUploadedFile::wrapper($request->file('file')); // $laravelUploadedFile 此时所有功能同 `Illuminate\Http\UploadedFile` } }