1. Go to this page and download the library: Download larasell-dev/chronicle 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/ */
use Larasell\Chronicle\WideEvents\Requests\Middleware\LogRequests;
->withMiddleware(function (Middleware $middleware): void {
$middleware->prepend(LogRequests::class);
})
use Larasell\Chronicle\Facades\Chronicle;
Chronicle::add('cart', ['items' => 3, 'total' => 8900]);
use Larasell\Chronicle\Facades\Chronicle;
use Larasell\Chronicle\WideEvents\Enums\Level;
Chronicle::record('inventory.low', ['sku' => 'SKU-42', 'stock' => 2], Level::Warning);
Chronicle::recordError($exception, ['order.id' => 7]);
use Larasell\Chronicle\Exceptions\StructuredRuntimeException;
throw new StructuredRuntimeException(
errorCode: 'billing.card-declined',
message: 'Payment failed: card declined',
why: 'The issuer declined the charge',
fix: 'Try a different card',
);
use Larasell\Chronicle\Exceptions\HasStructuredException;
use Larasell\Chronicle\Exceptions\StructuredException;
final class PaymentDeclined extends Exception implements StructuredException
{
use HasStructuredException;
public static function byIssuer(): self
{
return self::structured(
errorCode: 'billing.card-declined',
message: 'Payment failed: card declined',
fix: 'Try a different card',
);
}
}
use Larasell\Chronicle\Facades\Chronicle;
it('records the checkout', function () {
$chronicle = Chronicle::fake();
$this->post('/checkout');
$chronicle->assertRecorded('request', fn (array $event) => $event['cart.items'] === 3);
});