PHP code example of tourze / json-rpc-log-bundle

1. Go to this page and download the library: Download tourze/json-rpc-log-bundle 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/ */

    

tourze / json-rpc-log-bundle example snippets




use Tourze\JsonRPCLogBundle\Attribute\Log;
use Tourze\JsonRPCCore\Procedure\BaseProcedure;

#[Log(request: true, response: true)]
class CreateUserProcedure extends BaseProcedure
{
    public function process(): array
    {
        // Your JsonRPC procedure logic
        return ['status' => 'success', 'user_id' => 123];
    }
}

// Log only requests (privacy-sensitive responses)
#[Log(request: true, response: false)]
class SensitiveDataProcedure extends BaseProcedure { }

// Log only responses (when request data is not important)
#[Log(request: false, response: true)]
class ReadOnlyProcedure extends BaseProcedure { }

// Log everything (default)
#[Log(request: true, response: true)]
class StandardProcedure extends BaseProcedure { }



use Tourze\JsonRPCLogBundle\Interface\LogFormatProcedure;

class CustomLogFormatter implements LogFormatProcedure
{
    public function format(array $data): array
    {
        // Custom formatting logic
        return $data;
    }
}

// In your services.yaml
services:
    Tourze\JsonRPCLogBundle\Monolog\PayloadLogProcessor:
        tags:
            - { name: monolog.processor }
bash
php bin/console doctrine:migrations:migrate