承接 beauty-framework/core 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

beauty-framework/core

Composer 安装命令:

composer require beauty-framework/core

包简介

Beauty core

关键字:

README 文档

README

The beauty-framework/core package is the foundation of the Beauty Framework — a PSR-compliant, high-performance runtime for building clean and maintainable REST and gRPC (todo) services. It brings together routing, middleware, dependency injection, event system, and configuration management into a modular and lightweight package optimized for use with RoadRunner.

Features

  • Clean architecture: Separation of concerns, modular components.
  • PSR standards: PSR-7, PSR-11, PSR-14, PSR-15 compliance.
  • Route registration via PHP Attributes.
  • Simple and extendable DI container using php-di.
  • Attribute-based and runtime middleware pipeline.
  • Event dispatcher and listener registration (PSR-14 compatible).
  • Lightweight config system with runtime registry.
  • CLI kernel with support for custom commands.

Installation

composer require beauty-framework/core

Usage

App Kernel

Kernel\App is the main entry point for your application. It boots the container, registers routes, middleware, events, and config, and starts request handling.

use Beauty\Kernel\App;

require 'vendor/autoload.php';

$container = ContainerManager::bootFrom([
    \App\Container\Base::class,
    \App\Container\DI::class,
]);

$app = new App(
    container: $container,
);

$app->handle($request);

See in workers/http-worker.php in beauty-framework/app for a real-world example.

Routing System

beauty-framework/core includes an attribute-driven router with support for method-based route definitions and route-specific middleware.

Basic Example

use Beauty\Core\Router\Route;

class UserController
{
    #[Route(method: \Beauty\Http\Enums\HttpMethodsEnum::GET, path: '/users')]
    public function index(HttpRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return new JsonResponse(200, [
            'name' => $request->json('name'),
        ]);
    }
}

Generate via CLI:

./beauty generate:controller UserController
./beauty generate:request UserRequest

Dependency Injection (Container)

The framework uses a custom ContainerManager that wraps php-di and provides:

  • Singleton bindings
  • Auto-wiring
  • Runtime container access via ContainerRegistry
  • ContainerAwareInterface for injecting container where needed
use Beauty\Container\ContainerManager;

$container = ContainerManager::bootFrom([
    \App\Container\Base::class,
    \App\Container\DI::class,
]);

$service = $container->get(SomeService::class);

Configuration

Configuration is loaded from PHP files in config/*.php, and accessed via config function:

use Beauty\Config\ConfigRepository;

$config = config('app.debug');

At runtime, the ConfigRegistry provides in-memory updates or overrides.

Event System

beauty-framework/core ships with a PSR-14-compatible event dispatcher. You can define events and listeners:

Event

class UserRegisteredEvent 
{
    public function __construct(
        public string $email
    ) {}
}

Listener

class SendWelcomeEmailListener 
{
    public function handle(UserRegisteredEvent $event): void 
    {
        // Send email
    }
}

Registering

Use ListenerRegistry:

Or generate via CLI:

./beauty generate:event UserRegistered
./beauty generate:listener SendWelcomeEmail

🧵 Middleware

The router supports global and route-specific middleware using PSR-15-style interfaces.

use Beauty\Http\Middleware\MiddlewareInterface;

class AuthMiddleware implements MiddlewareInterface 
{
    public function process(HttpRequest $request, RequestHandlerInterface $handler): ResponseInterface 
    {
        // Auth check
        return $handler->handle($request);
    }
}

You can also use attributes like #[Middleware([AuthMiddleware::class])] on controller classes or methods.

Generate with stubs:

./beauty generate:middleware Hello

CLI Kernel

Define and register commands in config/commands.php, and they’ll be loaded automatically by the console kernel:

class SomeCommand extends AbstractCommand 
{
    protected string $name = 'hello';

    public function handle(array $args): int 
    {
        $this->line('Hello, world!');
        
        return CLI::SUCCESS;
    }
}

Or generate with stubs:

./beauty generate:command Hello

Testing

Coming soon: feature and unit tests for routing, DI, config, and event dispatching.

PSR Compliance

Standard Status
PSR-1
PSR-4
PSR-7
PSR-11
PSR-15
PSR-14

Helpers

  • helpers/di.php – short helpers to access DI bindings.
  • helpers/env.php.env parsing and usage functions.

License

MIT

Contributing

Pull requests and discussions are welcome! Let's make this the most developer-friendly framework for building modern PHP services.

Related Modules

beauty-framework/core 适用场景与选型建议

beauty-framework/core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「core」 「beauty」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 beauty-framework/core 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-10