PHP code example of alen-dev / xpath-log

1. Go to this page and download the library: Download alen-dev/xpath-log 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/ */

    

alen-dev / xpath-log example snippets


return [
    'driver_map' => [
        'cli' => \AlenDev\XpathLog\Drivers\CliDriver::class,
        'json' => \AlenDev\XpathLog\Drivers\JsonFileDriver::class,
        'log'  => \AlenDev\XpathLog\Drivers\LogFileDriver::class,
    ],
    'external_driver_map' => [],
    'default_drivers' => explode(',', env('XPATH_LOG_DEFAULT_DRIVERS', 'cli,log')),
    'file_name' => env('XPATH_LOG_FILENAME', 'xpath'),
];
bash
php artisan vendor:publish --tag=xpath-log-config
bash
XPATH_LOG_DEFAULT_DRIVERS="cli,log"
XPATH_LOG_FILENAME=xpathlog
bash
$xPathLog
    ->use('json')
    ->startTransaction('TX-789', ['customerId' => 123]);
$xPathLog
    ->use('json')
    ->endTransaction('TX-789', ['status' => 'success']);
bash
$xPathLog
    ->use('json')
    ->transaction('abc-123', 'Applied discount', ['code' => 'SUMMER']);
bash
php artisan xpathlog:create-sample
bash
php artisan xpathlog:view
bash
php artisan xpathlog:view --level=error
php artisan xpathlog:view --search=payment
php artisan xpathlog:view --date=2025-08-01
php artisan xpathlog:view --from="2025-08-01" --to="2025-08-02"
php artisan xpathlog:view --search=payment --from="yesterday"
bash
XPATH_LOG_ENABLE_REQUEST_LOGGER=true
bash
XPATH_LOG_MIDDLEWARE_GROUP=api