PHP code example of tripteki / laravelphp-supervisor
1. Go to this page and download the library: Download tripteki/laravelphp-supervisor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tripteki / laravelphp-supervisor example snippets
/** 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);