定制 devlite/php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

devlite/php

Composer 安装命令:

composer require devlite/php

包简介

DevLite PHP SDK — Error tracking and performance monitoring for PHP applications

README 文档

README

Error tracking and performance monitoring for PHP applications.

Installation

composer require devlite/php

Supported Frameworks

  • Laravel - composer require devlite/php (auto-integrated)
  • Symfony - composer require devlite/php
  • WordPress - composer require devlite/php
  • CodeIgniter
  • Yii
  • CakePHP

Quick Start

<?php
require_once 'vendor/autoload.php';

use DevLite\DevLite;

DevLite::init([
    'dsn' => 'https://devlite.andasy.dev/api/metrics',
    'app_name' => 'my-app',
    'environment' => 'production'
]);

try {
    // your code
    $result = 1 / 0;
} catch (Throwable $e) {
    DevLite::captureException($e);
    throw $e;
}

API Reference

Initialization

DevLite::init([
    'dsn' => 'https://...',          // required
    'app_name' => 'my-app',          // default: APP_NAME env var
    'environment' => 'production',   // default: ENV env var
    'release' => 'v1.0.0',          // default: VERSION env var
    'sample_rate' => 1.0,              // sample rate (0.0-1.0)
]);

Capture Exception

try {
    risky_operation();
} catch (Throwable $e) {
    DevLite::captureException($e);
}

Capture Message

DevLite::captureMessage('User logged in', 'info');

Performance Tracking

$start = hrtime(true);
// your code
$durationMs = (hrtime(true) - $start) / 1_000_000;
DevLite::capturePerformance('database_query', $durationMs);

User Context

DevLite::setUser('123', 'user@example.com', 'username');

Middleware (PSR-15)

$app->use(DevLite::middleware());

Laravel Integration

// config/devlite.php
return [
    'dsn' => env('DEVLITE_DSN'),
    'app_name' => env('APP_NAME'),
    'environment' => env('APP_ENV'),
    'release' => env('APP_VERSION'),
];

// app/Exceptions/Handler.php
public function report(Throwable $e): void
{
    app(DevLite\Client::class)->captureException($e);
    parent::report($e);
}

WordPress Integration

// wp-config.php
require_once 'vendor/autoload.php';
DevLite::init(['dsn' => 'https://...']);

Environment Variables

Variable Description
DEVLITE_DSN DevLite DSN URL
APP_NAME Application name
ENV Environment (default: development)
VERSION Release version

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固