tripteki / laravelphp-supervisor
Trip Teknologi's Laravel.php Supervisor
1.0.0
2024-05-21 16:15 UTC
Requires
- php: ^8.0.2
- ext-swoole: *
- beyondcode/laravel-websockets: ^2.0.0-beta.37
- guzzlehttp/guzzle: ^7.5.0
- laravel/octane: ^1.3.9
- pusher/pusher-php-server: 7.0.0
- tripteki/laravelphp-notification: ^1.0.0
README
This package provides supervisor-like, async-like, child-process-like, etc to build event-listener driven with little painless for your Laravel Project.
Getting Started
Installation :
$ composer require tripteki/laravelphp-supervisor
$ npm install pm2 && npm install --save-dev chokidar
$ pecl install swoole
How to use :
- Publish config file into your project's directory with running :
php artisan vendor:publish --tag=tripteki-laravelphp-supervisor
Usage
php artisan supervisor:<option>
Option
start ...
: Start the supervisor.- foreground (default)
- background
reload
: Reload the background supervisor.stop
: Stop the background supervisor /ctrl + c
for foreground supervisor.status
: Show the status of background supervisor.startup
: Generateecosystem.json
supervisor startup configuration, do not forget to stop your supervisor process perproject, then see this to know how to get started.
Snippet
/** Use asynchronous? */ __async__(function () { Model::truncate(); });
/** Use asynchronous await-like to get variable? */ [ $model, ] = __async__(fn () => Model::all());
/** Use setInterval? */ __setInterval__(function () { Model::truncate(); }, 2000);
/** Use setImmediate? */ __setImmediate__(function () { Model::truncate(); }, 2000);
/** Use exec as replace temporary process? */ $os = __exec__("uname -a");
/** Use spawn as one way communication child process? */ /** Stdin stream handler... */ $stdin = fopen("php://temporary", "w+"); fwrite($stdin, "Foo..."); fwrite($stdin, "Bar..."); fwrite($stdin, "Baz..."); fclose($stdin); /** Stdout handler... */ $stdout = function ($isError, $data) { if ($isError) { // $isError // } // $data // }; __spawn__("python3 example.py", $environment = [], $stdout, $stdin);
Author
- Trip Teknologi (@tripteki)
- Hasby Maulana (@hsbmaulana)