glesys / butler-service
Web service library based on Laravel
Installs: 18 132
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 11
Forks: 1
Open Issues: 0
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-11-28 08:52:14 UTC
README
🚧 Not ready for production.
Butler Service
A Laravel-based micro-framework for web services using GraphQL.
Getting Started
Requires a working Laravel app with a database connection.
composer require glesys/butler-service
Replace Illuminate\Foundation\Application
with Butler\Service\Foundation\Application
in bootstrap/app.php
.
php artisan vendor:publish --tag=butler-config --tag=butler-assets php artisan migrate
It is optional (but recommended) to extend your TestCase
(or whatever file that extends Laravels TestCase
) with Butler\Service\Testing\TestCase
.
use Butler\Service\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { // }
Service Providers
All service providers in your app/Providers
directory will be registered automatically.
Config
You can use your configuration files as usual. See src/config for our defaults.
ℹ️ Remember that your applications config/butler.php
only merges the first level of the default configuration.
Views
Views can be updated by publishing them:
php artisan vendor:publish --tag=butler-views
Extra
If you dont want a config/app.php
you can use butler.service.extra
in config/butler.php
to add "config". Note that "config" will not merge with existing config.
// example 'config' => [ 'foo' => 'bar', 'trustedproxy.proxies' => [ '10.0.0.0/8', ], ],
index.php
To keep your applications "index.php" up to date you can publish the one in butler-service.
ℹ️ Maintenance mode is not supported.
php artisan vendor:publish --force --tag=butler-index
Authentication with OAuth
Configure butler.sso
in config/butler.php
.
Set butler.sso.fake
to true
to fake to login process.
See laravel/socialite for more information.
Authentication with butler-auth
$consumer = \Butler\Service\Models\Consumer::create(['name' => 'Service A']); $token = $consumer->createToken(abilities: ['*'], name: 'token-name')->plainTextToken;
See butler-auth for more information.
Authorization
GraphQL operations are authorized by the "graphql" Gate
ability defined in the ServiceProvider.
// 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');
GraphQL with butler-graphql
See butler-graphql.
Audit with butler-audit
See butler-audit.
Health checks with butler-health
See butler-health for more information.
Testing
vendor/bin/phpunit vendor/bin/pint --test
How To Contribute
Development happens at GitHub; any typical workflow using Pull Requests are welcome. In the same spirit, we use the GitHub issue tracker for all reports (regardless of the nature of the report, feature request, bugs, etc.).
Code standard
As the library is intended for use in Laravel applications we encourage code standard to follow upstream Laravel practices - in short that would mean PSR-2 and PSR-4.