1. Go to this page and download the library: Download kislayphp/persistence 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/ */
kislayphp / persistence example snippets
Kislay\Persistence\Runtime::attach($app); // that's it
$app = new Kislay\Core\App();
// Attach persistence — handles begin/commit/rollback per request automatically
Kislay\Persistence\Runtime::attach($app);
$app->post('/api/orders', function($req, $res) {
$data = $req->getJson();
// Transaction is already open — just write your business logic
$orderId = DB::create('orders', $data);
Inventory::decrement($data['product_id'], $data['qty']);
Email::queue('order_confirmation', $data['email']);
$res->json(['order_id' => $orderId], 201);
// Transaction commits automatically on clean return
// Transaction rolls back automatically on exception
});
$app->listen('0.0.0.0', 8080);
namespace Kislay\Persistence;
class Runtime {
public function __construct();
public static function attach(Kislay\Core\App $app): void; // per-request auto lifecycle
public function begin(): bool;
public function commit(): bool;
public function rollback(): bool;
public function isActive(): bool;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.