labrador-kennel/framework 问题修复 & 功能扩展

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

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

labrador-kennel/framework

Composer 安装命令:

composer require labrador-kennel/framework

包简介

A framework for building asynchronous applications with Amp and Annotated Container.

README 文档

README

GitHub license GitHub release

Labrador is still in heavy development. A 1.0.0-alpha release is near but the API is still highly volatile and subject to change!

Labrador is a microframework built on-top of Amphp and Annotated Container. It offers a non-traditional way of writing small-to-medium sized applications in PHP. Among its many features includes:

  • Everything in pure PHP. Have a fully-featured web server up with php app.php
  • Declarative approach to dependency injection
  • Comprehensive, secure solution for handling configuration
  • Asynchronous by default
  • Robust, data-rich event system for knowing when things happen
  • An easy-to-use HTTP and routing layer

If you're looking for a more complete skeleton to get started with writing Labrador-powered apps, you should check out labrador-kennel/web-app; it is a skeleton for a complete app, including Docker setup, database, and templating.

Install

Use Composer to install the library.

composer require labrador-kennel/framework

Requirements

This is a step-by-step guide to the code you'll need to implement to get this framework serving HTTP requests. This is not meant to be a comprehensive guide on how to deploy in production, but how to get up and running on your local machine.

Step 1: Logging

A critical step that MUST be completed, otherwise your application will not start up. To satisfy this requirement you must implement a Labrador\Logging\LoggerFactory and mark it as a service to be managed by the dependency injection container. Somewhere in your src/ directory, or some other directory that is autoloaded and scaned by Annotated Container, write some code that resembles the following:

<?php declare(strict_types=1);

namespace App;

use Amp\Log\StreamHandler;
use Cspray\AnnotatedContainer\Attribute\Service;
use Labrador\Logging\LoggerFactory;
use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use Psr\Log\LoggerInterface;
use function Amp\ByteStream\getStdout;

#[Service]
final class MyLoggerFactory implements LoggerFactory {

    public function createLogger() : LoggerInterface{
        return new Logger(
            'my-logger-name',
            [new StreamHandler(getStdout())],
            [new PsrLogMessageProcessor()]
        );
    }


}

This is a minimal setup that could be applicable if your app is running in a Docker container. It will stream log output to stdout using Amp-provided mechanisms. It is important to use a Monolog handler provided by Amp, to avoid blocking I/O operations.

Again, this is a highly important step that you MUST complete. If you get an error from your dependency injection container stating that a LoggerFactory cannot be instantiated, completing this step is your resolution.

TODO: Determine and document precise steps would need to result in a running app

labrador-kennel/framework 适用场景与选型建议

labrador-kennel/framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 380 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-15