yupmin / laravel-phystrix
An easy to use Phystrix integration for Laravel applications
Installs: 1 601
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.4|^8.0|^8.1|^8.2
- ext-apcu: *
- ext-json: *
- yupmin/modern-phystrix: ^5.0
Requires (Dev)
- nunomaduro/collision: ^4.3|^5.11|^6.3
- orchestra/testbench: ^5.0|^6.0|^7.0
- squizlabs/php_codesniffer: ^3.7
README
Laravel Phystrix Package using by Modern Phystrix
Requirements
- PHP 7.1 above
- ext-json
- ext-apcu
- Laravel 5.5 above
Installation
composer require yupmin/laravel-phystrix
Install config
php artisan vendor/publish --provider=Yupmin\Phystrix\ServiceProvider
How to use
Make Phystrix Command
php artisan make:phystrix-command TestCommand
Edit file 'app/Phystrix/TestCommand.php'
class TestCommand extends AbstractCommand { protected $wantFallback; public function __construct($wantFallback = false) { $this->wantFallback = $wantFallback; } /** * @param bool $wantFallback * @return mixed * @throws Exception */ protected function run() { if ($this->wantFallback) { throw new Exception("fallback"); } return 'run test'; } /** * @param Exception|null $exception * @return mixed */ protected function getFallback(?Exception $exception = null) { return $exception->getMessage(); } }
Run TestCommand
phystrinx(App\Phystrix\TestCommand::class)->execute(); // => "run test" phystrinx(App\Phystrix\TestCommand::class, false)->execute(); // => "fallback"
Run Phystrix Stream for dashboard (apcu
is required.)
Route::get('/phystrix.stream', function () { phystrix_stream()->run(); });
License
The MIT License (MIT). Please see License File for more information.