bear/devtools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bear/devtools

Composer 安装命令:

composer require bear/devtools

包简介

README 文档

README

Development tools and utilities for BEAR.Sunday framework applications.

Latest Stable Version Total Downloads License

Installation

composer require --dev bear/devtools

Features

Halo Module - Resource Development Inspector

The Halo module provides a visual development interface that appears around HTML representations of resources, offering detailed information about the resource being rendered.

Note: The Halo concept is inspired by the Seaside Smalltalk web framework, which pioneered this approach to visual web development debugging.

Features:

  • Resource status and metadata display
  • Interceptor chain visualization
  • Direct links to resource class and template editors
  • Request/response analysis
  • Performance profiling integration
use BEAR\Dev\Halo\HaloModule;
use Ray\Di\AbstractModule;

class DevModule extends AbstractModule
{
    protected function configure(): void
    {
        $this->install(new HaloModule($this));
    }
}

HttpResource Client - HTTP Testing Utility

HttpResource starts a built-in PHP server and provides an HTTP client interface for testing your BEAR.Sunday applications.

Features:

  • Automatic local server startup
  • HTTP request logging (to STDERR, a single file, or per-test files)
  • Full HTTP method support (GET, POST, PUT, PATCH, DELETE)
  • HAL link following with href()
  • Request/response capture for testing workflows
use BEAR\Dev\Http\HttpResource;

// Start the built-in server and create an HTTP client.
// The third argument is the log destination and is optional
// (defaults to 'php://stderr'):
//   - 'php://stderr'       : write logs to STDERR (default)
//   - '/path/to/file.log'  : write every request to a single file
//   - '/path/to/log'       : a directory; one '<test-name>.log' per test method
$resource = new HttpResource('127.0.0.1:8080', '/path/to/public/index.php', __DIR__ . '/log');

// Make HTTP requests
$ro = $resource->get('/users');
assert($ro->code === 200);

$ro = $resource->post('/users', ['name' => 'John', 'email' => 'john@example.com']);
assert($ro->code === 201);

Following HAL links

href() follows a HAL _links relation from a response with a GET request:

$index = $resource->get('/');
// {"_links": {"next": {"href": "/users"}}}

$users = $resource->href('next', [], $index);
assert($users->code === 200);

A HalLinkNotFoundException is thrown when the relation or its href is missing.

HTTP Access Log

Each request is logged with its equivalent curl command followed by the raw response:

curl -s -i 'http://127.0.0.1:8080/users'

HTTP/1.1 200 OK
Content-Type: application/hal+json
...

Workflow Testing

AbstractWorkflowTest is the base contract for rel-driven workflow tests. Write the workflow once against ResourceInterface, then run the same scenario over HTTP by extending the concrete workflow test and overriding only newResource() with HttpResource.

use BEAR\Dev\Http\AbstractWorkflowTest;
use BEAR\Resource\ResourceInterface;
use BEAR\Resource\ResourceObject;
use MyVendor\MyProject\Injector;

use function assert;

class WorkflowTest extends AbstractWorkflowTest
{
    protected function newResource(): ResourceInterface
    {
        $resource = Injector::getInstance('app')->getInstance(ResourceInterface::class);
        assert($resource instanceof ResourceInterface);

        return $resource;
    }

    public function testIndex(): ResourceObject
    {
        $index = $this->resource->get('/index');
        $this->assertSame(200, $index->code);

        return $index;
    }

    /** @depends testIndex */
    public function testNext(ResourceObject $response): ResourceObject
    {
        return $this->follow($response, 'next');
    }
}
use BEAR\Dev\Http\HttpResource;
use BEAR\Resource\ResourceInterface;
use MyVendor\MyProject\Hypermedia\WorkflowTest as Workflow;

class WorkflowTest extends Workflow
{
    protected function newResource(): ResourceInterface
    {
        return new HttpResource('127.0.0.1:8088', __DIR__ . '/index.php', __DIR__ . '/log');
    }
}

Requirements

  • PHP 8.2 or higher
  • ext-curl
  • BEAR.Sunday framework

Development

This package includes comprehensive development tools:

  • Code Quality: PHPStan, Psalm, PHP_CodeSniffer
  • Testing: PHPUnit with coverage reporting
  • Profiling: XHProf integration (optional)

License

The MIT License (MIT). Please see License File for more information.

bear/devtools 适用场景与选型建议

bear/devtools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 260.32k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 bear/devtools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bear/devtools 我们能提供哪些服务?
定制开发 / 二次开发

基于 bear/devtools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 260.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 14
  • 依赖项目数: 3
  • 推荐数: 1

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-13