1. Go to this page and download the library: Download havn/laravel-executable 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/ */
havn / laravel-executable example snippets
use Havn\Executable\QueueableExecutable;
class ProcessPayment
{
use QueueableExecutable;
public function __construct(
private PaymentGateway $gateway,
) {}
public function execute(Payment $payment): void
{
$this->gateway->charge($payment);
$payment->update(['status' => 'completed']);
}
}
// Sync — runs immediately, returns the result
ProcessPayment::sync()->execute($payment);
// Queue — dispatches to the queue
ProcessPayment::onQueue()->execute($payment);
// Prepare — returns a job without dispatching (for chains and batches)
$job = ProcessPayment::prepare()->execute($payment);
// Test — runs the real code in a testable context
ProcessPayment::test()->execute($payment);