suvera/winter-boot 问题修复 & 功能扩展

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

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

suvera/winter-boot

Composer 安装命令:

composer require suvera/winter-boot

包简介

Winter Boot Framework

README 文档

README

Inspired by the elegance of Spring Boot, Winter Boot empowers you to build robust and scalable microservices in PHP 8 with unparalleled ease and familiarity. If you're a Spring Boot enthusiast looking to dive into the world of PHP, Winter Boot is your perfect gateway!

Effortless Application Setup:

Get your Winter Boot application up and running in no time. The @WinterBootApplication attribute simplifies your main application class, making bootstrapping a breeze.

#[WinterBootApplication]
class MyApplication {

    public static function main() {
        (new WinterWebSwooleApplication())->run(MyApplication::class);
    }

}

MyApplication::main();

Key Features that will make you love Winter Boot:

  • Dependency Injection with PHP 8 Attributes: Say goodbye to complex configurations! Winter Boot leverages the power of PHP 8 Attributes (Annotations) for seamless and intuitive dependency injection.

Build Powerful Services with Ease

Craft your services and REST APIs with a clean, attribute-driven approach.

Example Service Implementation:

Define your services with the @Service attribute and inject dependencies effortlessly using @Autowired.

#[Service]
class UserServiceImpl implements UserService {

    #[Autowired]
    private PdbcTemplate $pdbc;

    public function createUser(string $name, string $email) {
        $this->pdbc->update(/* ... */);
    }
}

Crafting RESTful APIs:

Transform your classes into powerful REST controllers using @RestController and map your endpoints with @RequestMapping. Handling requests and returning ResponseEntity has never been this elegant!

#[RestController]
class MyController {

    #[Autowired]
    private UserService $userService;


    #[RequestMapping(path: "/api/v2/users", method: [RequestMethod::POST]]
    public function createUser(
        #[RequestParam] string $name,
        #[RequestParam] string $email
    ): ResponseEntity {
        $this->userService->createUser($name, $email);
        
        return ResponseEntity::ok()->withJson($someJsonArray);
    }
}

Test Your API Instantly:

Quickly test your newly created API endpoint with a simple curl command.

curl "http://localhost/api/v2/users" -d "name=Abc&email=mail"

1. Explore a Live Example Microservice

Dive into a complete, working example of a Winter Boot microservice to see it in action! Check out the example application here example-service

2. Getting Started: Installation

Ready to build amazing things with Winter Boot? Follow these simple steps to get started!

  1. Prerequisite: Ensure you have PHP 8.0 (or greater) installed.

  2. Unleash Asynchronous Power (Optional but Recommended): For blazing-fast asynchronous functions (#[Async]) and scheduled tasks (#[Scheduled]), the swoole extension is highly recommended.

pecl install swoole

Seamless Installation with Composer

Integrate Winter Boot into your project effortlessly using Composer.

composer require suvera/winter-boot

composer require suvera/winter-modules

You're Done! Get ready to code!

3. Build & Deploy Your Winter Boot Applications

Winter Boot provides robust support for building and deploying your services, leveraging the powerful Phing build system.

Explore our comprehensive guide on Building Services to learn how to:

  • Generate optimized Phar files for easy distribution.
  • Effortlessly build Docker Images for containerized deployments. See a practical example in the example-service repository:

4. In-Depth Documentation

Unlock the full potential of Winter Boot with our detailed documentation. Each guide is crafted to help you master specific aspects of the framework:

5. Extend Your Horizons with Module Extensions

Winter Boot is designed for extensibility! Expand its capabilities even further by integrating powerful modules from the Winter Modules project.

Craft Your Own Modules!

Want to contribute or build a custom integration? Creating a new module is straightforward! Simply extend [WinterModule](src/core/app/WinterModule.php). Check out these existing modules for inspiration and reference:

6. Frequently Asked Questions (FAQ)

Got questions? We've got answers!

1. Can I integrate components from other PHP frameworks into my Winter Boot project?

Absolutely! Winter Boot is designed to be highly interoperable. You can seamlessly incorporate any component from popular PHP frameworks like Symfony, Yii2, Laravel, CodeIgniter, and more, simply by using Composer.

Examples:

# Symfony Security component
composer require symfony/security


# Laravel illuminate events component
composer require illuminate/events


# Yii Arrays Component
composer require yiisoft/arrays --prefer-dist

Important: Always ensure that the components you integrate are compatible with PHP 8.0+.

2. Is it possible to use RoadRunner or Workerman with Winter Boot?

Yes, indeed! Winter Boot's flexible architecture allows you to extend the framework and create your own core Application runner classes to support different server environments.

Current Swoole Integration:

Winter Boot already provides a robust integration with Swoole:

class WinterWebSwooleApplication extends WinterApplicationRunner implements WinterApplication {
}

Your Custom Integrations:

You can follow the same pattern to integrate with RoadRunner, Workerman, or any other server:

class WinterWebWorkermanApplication extends WinterApplicationRunner implements WinterApplication {
}

class WinterRoadRunnerApplication extends WinterApplicationRunner implements WinterApplication {
}

suvera/winter-boot 适用场景与选型建议

suvera/winter-boot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 27, 最近一次更新时间为 2021 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 suvera/winter-boot 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 27
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-10