PHP code example of perfbase / codeigniter4

1. Go to this page and download the library: Download perfbase/codeigniter4 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/ */

    

perfbase / codeigniter4 example snippets


public bool $enabled = false;
public bool $debug = false;
public bool $logErrors = true;
public string $apiKey = '';
public string $apiUrl = 'https://ingress.perfbase.cloud';
public float $sampleRate = 0.1;
public int $timeout = 10;
public ?string $proxy = null;
public int $flags = FeatureFlags::DefaultFlags;
public string $appVersion = '';
public ?string $userResolver = null;
public array|string $profileHttpStatusCodes = ''; // normalized to [...range(200, 299), ...range(500, 599)]
public array $



namespace Config;

use Perfbase\CodeIgniter4\Config\Perfbase as BasePerfbase;
use Perfbase\SDK\FeatureFlags;

final class Perfbase extends BasePerfbase
{
    public bool $enabled = true;
    public bool $debug = false;
    public bool $logErrors = true;
    public string $apiKey = '';
    public float $sampleRate = 0.2;
    public int $timeout = 10;
    public int $flags = FeatureFlags::DefaultFlags;
    public string $appVersion = '1.0.0';
    public array $profileHttpStatusCodes = [200, 201, 202, 204];
    public array $excludeHttp = ['/health', '/up'];
    public array $excludeConsole = ['cache:*', 'migrate:*'];
}

namespace App\Support;

use CodeIgniter\HTTP\RequestInterface;
use Perfbase\CodeIgniter4\Contracts\UserResolverInterface;

final class PerfbaseUserResolver implements UserResolverInterface
{
    public function resolve(RequestInterface $request): ?string
    {
        return '123';
    }
}

public ?string $userResolver = 'perfbaseUserResolver';

public ?string $userResolver = App\Support\PerfbaseUserResolver::class;

public bool $debug = true;
bash
php spark perfbase:install
bash
php spark perfbase:doctor
bash
php spark perfbase:install --alias-only
bash
php spark publish --namespace Perfbase\\CodeIgniter4
bash
php spark perfbase:doctor
bash
bin/test-compat --php 8.2 --framework 4.3.8
bin/test-compat --php 8.2 --framework 4.4.8
bin/test-compat --php 8.2 --framework 4.6.5
bash
php spark perfbase:install