1. Go to this page and download the library: Download applogger/sdk-core 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/ */
applogger / sdk-core example snippets
use function ApplicationLogger\Sdk\{init, captureException, captureMessage, addBreadcrumb, configureScope, withScope, flush, logger};
use ApplicationLogger\Sdk\{Breadcrumb, Severity};
// 1. Initialise once (typically in your bootstrap / front-controller).
init([
'dsn' => 'https://your-ingest-host.example.com/your-project-id',
'api_key' => 'your-api-key',
'environment' => 'production',
'release' => '1.4.2',
]);
// 2. Capture exceptions.
try {
riskyOperation();
} catch (\Throwable $e) {
captureException($e);
}
// 3. Capture a plain message.
captureMessage('Checkout completed', Severity::Info);
// 4. Add a breadcrumb.
addBreadcrumb(new Breadcrumb(
category: 'db',
message: 'User record loaded',
level: Severity::Debug,
data: ['user_id' => 42],
timestamp: new \DateTimeImmutable(),
));
// 5. Enrich the current scope (tags, user, extra).
configureScope(function (\ApplicationLogger\Sdk\Scope $scope): void {
$scope->setTag('plan', 'premium');
$scope->setUser(['id' => 42, 'email' => '[email protected]']);
$scope->setExtra('memory_mb', memory_get_usage(true) / 1048576);
});
// 6. Use an isolated scope for one block (does not affect the global scope).
withScope(function (\ApplicationLogger\Sdk\Scope $scope): void {
$scope->setTag('component', 'payment');
captureMessage('Payment gateway timeout', Severity::Warning);
});
// 7. PSR-3 logger for structured log aggregation (
use ApplicationLogger\Sdk\Hub;
// After init() (or after a framework adapter has constructed its own Hub):
$hub = Hub::getCurrent();
$hub->captureException($throwable);
$hub->captureMessage('Something happened', \ApplicationLogger\Sdk\Severity::Warning);
$hub->configureScope(function (\ApplicationLogger\Sdk\Scope $scope): void {
$scope->setTag('tenant', 'acme');
});
$hub->withScope(function (\ApplicationLogger\Sdk\Scope $scope): void {
// isolated scope
});