glesys / butler-service
基于Laravel的Web服务库
Requires
- php: ^8.2
- bugsnag/bugsnag-laravel: ^2.18
- glesys/butler-audit: ^0.8
- glesys/butler-auth: ^7.0
- glesys/butler-graphql: ^11.0
- glesys/butler-health: ^0.6
- graylog2/gelf-php: ^1.6
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^11.0
- laravel/octane: ^1.0 || ^2.0
- laravel/socialite: ^5.5
- laravel/tinker: ^2.9
Requires (Dev)
- fakerphp/faker: ^1.23.1
- laravel/pint: ^1.14
- mockery/mockery: ^1.6.9
- nunomaduro/collision: ^8.1.1
- phpunit/phpunit: ^10.5.13
- spatie/laravel-ignition: ^2.4.2
- dev-master
- dev-main
- v0.28.2
- v0.28.1
- v0.28.0
- v0.27.2
- v0.27.1
- v0.27.0
- v0.26.1
- v0.26.0
- v0.25.0
- v0.24.2
- v0.24.1
- v0.24.0
- v0.23.1
- v0.23.0
- v0.22.3
- v0.22.2
- v0.22.1
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.1
- v0.19.0
- v0.18.2
- v0.18.1
- v0.18.0
- v0.17.0
- v0.16.0
- v0.15.2
- v0.15.1
- v0.15.0
- v0.14.3
- v0.14.2
- v0.14.1
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.2
- v0.11.1
- v0.11.0
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.1
- v0.8.0
- v0.7.0
- v0.6.1
- v0.6.0
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.13
- v0.2.12
- v0.2.11
- v0.2.10
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- dev-dependabot/composer/phpunit/phpunit-tw-10.5.13or-tw-11.0.0
- dev-test-butler-health
- dev-default-octane-https
- dev-test-php81
- dev-read-write-maintenance
- dev-octane-disconnect-db
- dev-emil-nasso-bugsnag-config
- dev-add-consumers-endpoint
This package is auto-updated.
Last update: 2024-09-26 06:11:19 UTC
README
🚧 尚未准备用于生产。
Butler Service
使用GraphQL的Laravel微框架,用于构建Web服务。
入门指南
需要有一个具有数据库连接的正在运行的Laravel应用。
composer require glesys/butler-service
在 bootstrap/app.php
中将 Illuminate\Foundation\Application
替换为 Butler\Service\Foundation\Application
。
php artisan vendor:publish --tag=butler-config --tag=butler-assets php artisan migrate
扩展您的 TestCase
(或任何扩展Laravel TestCase
的文件)以使用 Butler\Service\Testing\TestCase
是可选的(但推荐)。
use Butler\Service\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { // }
服务提供者
您的 app/Providers
目录中的所有服务提供者将自动注册。
配置
您可以使用常规配置文件。有关默认配置,请参阅 src/config。
ℹ️ 请记住,您的应用程序的 config/butler.php
只会合并 默认配置 的第一级。
视图
可以通过发布来更新视图
php artisan vendor:publish --tag=butler-views
额外
如果您不想使用 config/app.php
,可以在 config/butler.php
中使用 butler.service.extra
来添加 "config"。注意,“config” 不会 与现有配置合并。
// example 'config' => [ 'foo' => 'bar', 'trustedproxy.proxies' => [ '10.0.0.0/8', ], ],
index.php
为了保持您的应用程序的 "index.php" 文件最新,您可以发布 butler-service 中的文件。
ℹ️ 不支持维护模式。
php artisan vendor:publish --force --tag=butler-index
使用OAuth进行身份验证
在 config/butler.php
中配置 butler.sso
。
将 butler.sso.fake
设置为 true
来模拟登录过程。
有关更多信息,请参阅 laravel/socialite。
使用butler-auth进行身份验证
$consumer = \Butler\Service\Models\Consumer::create(['name' => 'Service A']); $token = $consumer->createToken(abilities: ['*'], name: 'token-name')->plainTextToken;
有关更多信息,请参阅 butler-auth。
授权
GraphQL操作通过在 ServiceProvider 中定义的 "graphql" Gate
能力进行授权。
// allow "query" operations only $consumer->createToken(['query'], 'my read-only token'); // allow "mutation" operations only $consumer->createToken(['mutation'], 'my write-only token'); // allow specific operations $consumer->createToken(['query:ping'], 'my "ping" token'); $consumer->createToken(['query', 'mutation:start'], 'my "start" token'); // allow any operations $consumer->createToken(['*'], 'my full-access token'); $consumer->createToken(['query', 'mutation', 'subscription'], 'my graphql token');
使用butler-graphql进行GraphQL
请参阅 butler-graphql。
使用butler-audit进行审计
请参阅 butler-audit。
使用butler-health进行健康检查
请参阅 butler-health 以获取更多信息。
测试
vendor/bin/phpunit vendor/bin/pint --test
如何贡献
开发发生在GitHub上;任何使用Pull Requests的典型工作流程都是欢迎的。本着同样的精神,我们使用GitHub问题跟踪器来处理所有报告(无论报告的性质、功能请求、错误等)。
代码规范
由于该库旨在用于Laravel应用,我们鼓励遵循 Laravel上游实践 的代码规范 - 简而言之,这意味着遵循 PSR-2 和 PSR-4。