PHP code example of dnj / laravel-error-tracker-server
1. Go to this page and download the library: Download dnj/laravel-error-tracker-server 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/ */
dnj / laravel-error-tracker-server example snippets
return [
// Define your user model class for connect entities to users.
'user_model' => \dnj\AAA\Models\User::class,
'routes' => [
'enable' => true,
'prefix' => 'log', // example: log, device, etc ... ,
],
];
use dnj\ErrorTracker\Contracts\IAppManager;
use dnj\ErrorTracker\Contracts\IDeviceManager;
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;
$appManager = app(IAppManager::class);
$app = $appManager->store(
title: 'Android mobile app',
owner: 1,
meta: ['key' => 'value']),
userActivityLog: false,
);
$deviceManager = app(IDeviceManager::class);
$device = $deviceManager->store(
title: 'Nokia mobile',
owner: 1,
meta: ['serialNo' => 44514526985]),
userActivityLog: false,
);
$logManager = app(ILogManager::class);
$log = $logManager->store(
app: $app,
device: $device,
level: LogLevel::INFO,
message: 'App just installed',
data: ['version' => "1.0.0"]
);
use dnj\ErrorTracker\Contracts\IAppManager;
$appManager = app(IAppManager::class);
$apps = $appManager->search(
filters: [
'title' => 'mobile app'
'owner' => 2
],
);
use dnj\ErrorTracker\Contracts\IAppManager;
$appManager = app(IAppManager::class);
$app = $appManager->store(
title: 'Android mobile app',
owner: 1,
meta: ['key' => 'value']),
userActivityLog: false,
);
use dnj\ErrorTracker\Contracts\IAppManager;
$appManager = app(IAppManager::class);
$app = $appManager->update(
app: 1,
changes: [
'title' => 'new title',
'owner' => 2,
],
userActivityLog: true,
);
use dnj\ErrorTracker\Contracts\IAppManager;
$appManager = app(IAppManager::class);
$appManager->destroy(
log: 1,
userActivityLog: false,
);
use dnj\ErrorTracker\Contracts\IDeviceManager;
$deviceManager = app(IDeviceManager::class);
$devices = $deviceManager->search(
filters: [
'title' => 'Nokia Mobile'
'owner' => 2
],
);
use dnj\ErrorTracker\Contracts\IDeviceManager;
$deviceManager = app(IDeviceManager::class);
$device = $deviceManager->store(
title: 'Nokia mobile',
owner: 1,
meta: ['key' => 'value']),
userActivityLog: false,
);
use dnj\ErrorTracker\Contracts\IDeviceManager;
$deviceManager = app(IDeviceManager::class);
$device = $deviceManager->update(
device: 3,
changes: [
'title' => 'My Nokia Mobile',
'owner' => 2,
'meta' => ['serialNo' => 55245252]
],
userActivityLog: true,
);
use dnj\ErrorTracker\Contracts\IDeviceManager;
$deviceManager = app(IDeviceManager::class);
$deviceManager->destroy(
log: 3,
userActivityLog: false,
);
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;
$logManager = app(ILogManager::class);
$logs = $logManager->search(
filters: [
'apps' => [1,2],
'devices' => [1],
'levels' => [LogLevel::DEBUG],
'message' => 'important flag',
'unread' => true,
]
);
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;
$logManager = app(ILogManager::class);
$log = $logManager->store(
app: 1,
device: 1,
level: LogLevel::INFO,
message: 'App has been started',
);
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;
$logManager = app(ILogManager::class);
$log = $logManager->markAsRead(
log: 44,
user: 3
);
use dnj\ErrorTracker\Contracts\ILogManager;
use dnj\ErrorTracker\Contracts\LogLevel;
$logManager = app(ILogManager::class);
$log = $logManager->markAsUnread(
log: 44,
);
use dnj\ErrorTracker\Contracts\ILogManager;
$logManager = app(ILogManager::class);
$logManager->destroy(
log: 44,
userActivityLog: true,
);
./vendor/bin/phpunit
shell
php artisan vendor:publish --provider="dnj\ErrorTracker\Laravel\Server\ServiceProvider"