guardsmanpanda / larabear
使项目强大如熊。
v2.0.0
2024-07-15 23:17 UTC
Requires
- php: ^8.2
- ext-pdo: *
- ext-zend-opcache: *
- doctrine/dbal: ^4.0.3
- guzzlehttp/guzzle: ^7.8
- laravel/framework: ^v11.15
- ramsey/collection: ^2.0
Requires (Dev)
- ergebnis/phpstan-rules: ^2.2
- phpstan/phpstan: ^1.11
- phpstan/phpstan-deprecation-rules: ^1.2
- phpstan/phpstan-strict-rules: ^1.6
- roave/security-advisories: dev-latest
- thecodingmachine/phpstan-strict-rules: ^1.0
README
Larabear
使Laravel强大如熊!
安装
您可以通过composer安装此包
步骤 1
composer require guardsmanpanda/larabear
步骤 2
将服务提供者添加到 config/app.php
'providers' => [ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, ... \GuardsmanPanda\Larabear\Infrastructure\Laravel\Provider\BearServiceProvider::class, ],
步骤 3
发布所需的配置文件
php artisan vendor:publish --tag=bear
步骤 4
要测试和验证系统是否正确配置,您可以运行
php artisan bear
步骤 5
要启用大多数功能,请确保在所有路由上启用了 "BearInitiateMiddleware"
final class HttpKernel extends Kernel { // These middlewares are run during every request to your application. protected $middleware = [ \GuardsmanPanda\Larabear\Infrastructure\Http\Middleware\BearInitiateMiddleware::class, OtherMiddleware::class, ];
步骤 6
要过滤 "php artisan" 的控制台输出,将主 artisan 文件更改为
#!/usr/bin/env php <?php declare(strict_types=1); use GuardsmanPanda\Larabear\Infrastructure\Console\Service\ConsoleOutputFilter; define('LARAVEL_START', microtime(true)); require __DIR__.'/vendor/autoload.php'; $app = require __DIR__.'/bootstrap/app.php'; $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); $status = $kernel->handle($input = new Symfony\Component\Console\Input\ArgvInput, new ConsoleOutputFilter); $kernel->terminate($input, $status); exit($status);
用法
您可以通过使用 "Req" 类从请求中获得正确的类型检查数据
final class MyController extends Controller { public function myMethod(): JsonResponse { $data = Req::getString('data');
安全
如果您发现任何安全相关的问题,请通过电子邮件 guardsmanpanda@gmail.com 而不是使用问题跟踪器。
致谢
许可协议
MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件。