PHP code example of madeiteasytools / multiverse
1. Go to this page and download the library: Download madeiteasytools/multiverse 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/ */
madeiteasytools / multiverse example snippets
use MadeItEasyTools\Multiverse\Facades\Multiverse;
$result = Multiverse::run('image_processor', [
'image_url' => 'https://example.com/image.jpg'
]);
// $result = ['status' => 'success', 'processed' => '...']
// v2.x
Multiverse::run('image_processor', [
'image_url' => $imageUrl,
'driver' => 'python',
'_timeout' => 120,
]);
// v3.0
Multiverse::run('image_processor', ['image_url' => $imageUrl], [
'driver' => 'python',
'timeout' => 120,
]);
// config/multiverse.php
'timeout' => 60,
'max_timeout' => 300,
$result = Multiverse::run('worker_name', ['data' => 'value'], [
'driver' => 'python',
'timeout' => 120,
]);
use MadeItEasyTools\Multiverse\Exceptions\WorkerException;
use MadeItEasyTools\Multiverse\Exceptions\TimeoutException;
try {
$result = Multiverse::run('risky_worker', $data);
} catch (TimeoutException $e) {
// Worker exceeded timeout
Log::error('Worker timed out', [
'worker' => $e->getWorkerName(),
'timeout' => $e->getMessage()
]);
} catch (WorkerException $e) {
// Worker failed (exit code != 0)
Log::error('Worker failed', [
'worker' => $e->getWorkerName(),
'exit_code' => $e->getExitCode(),
'driver' => $e->getDriver()
]);
}
// config/multiverse.php
'logging' => [
'enabled' => true,
'channel' => env('LOG_CHANNEL', 'stack'),
],
'process' => [
'max_input_bytes' => 10 * 1024 * 1024,
'max_output_bytes' => 10 * 1024 * 1024, // Combined stdout and stderr.
'env_allowlist' => [
'PATH', 'SystemRoot', 'WINDIR', 'TEMP', 'TMP', 'TMPDIR', 'LANG', 'LC_ALL', 'LC_CTYPE',
],
],
$result = Multiverse::run('image_processor', $validatedData, [
'env' => ['WORKER_API_TOKEN' => config('services.worker.token')],
]);
// config/multiverse.php
return [
// Worker storage path
'workers_path' => base_path('multiverse'),
// Finite timeout and maximum, in seconds
'timeout' => 60,
'max_timeout' => 300,
// Automatic error logging
'logging' => [
'enabled' => true,
'channel' => env('LOG_CHANNEL', 'stack'),
],
// pip install/upgrade timeout in seconds
'pip_timeout' => 300,
// Python configuration
'python' => [
'root_path' => 'multiverse/python',
'venv_path' => 'multiverse/python/venv',
'
// Run TensorFlow/PyTorch models
$prediction = Multiverse::run('ml_model', [
'image' => base64_encode($imageData)
]);
// OpenCV operations
$processed = Multiverse::run('image_processor', [
'path' => storage_path('images/photo.jpg'),
'operation' => 'resize',
'width' => 800
]);
// Pandas/NumPy analysis
$analysis = Multiverse::run('data_analyzer', [
'csv_path' => storage_path('data.csv'),
'operation' => 'statistics'
]);
// BeautifulSoup/Scrapy
$data = Multiverse::run('scraper', [
'url' => 'https://example.com',
'selector' => '.product-price'
]);
bash
php artisan multiverse:check --lang=python
bash
php artisan multiverse:install --lang=python
bash
php artisan vendor:publish --tag=multiverse-config
bash
php artisan multiverse:worker image_processor --lang=python
[2026-02-08 12:00:00] local.ERROR: Multiverse worker failed
{
"worker": "image_processor",
"driver": "python",
"exit_code": 1,
"exception": "MadeItEasyTools\\Multiverse\\Exceptions\\WorkerException"
}
bash
$ php artisan multiverse:clear test_worker
Searching for processes matching worker: test_worker
Killed PID: 12345
✓ Killed 1 process(es)
bash
php artisan multiverse:update --lang=python
bash
php -r "echo ini_get('disable_functions');"
bash
# Remove proc_open from disable_functions in /etc/php/X.Y/fpm/php.ini
# Then restart PHP-FPM
systemctl restart php8.4-fpm