suvera / winter-boot
Winter Boot Framework
Requires
- ext-pcntl: *
- ext-posix: *
- lastguest/murmurhash: 2.1.*
- monolog/monolog: 2.3.*
- promphp/prometheus_client_php: v2.3.*
- ramsey/uuid: 4.2.*
- suvera/monolog-cascade: dev-master
- swoole/ide-helper: @dev
- symfony/yaml: 5.4.x-dev
- vanilla/garden-cli: v3.1
This package is auto-updated.
Last update: 2025-03-01 00:47:45 UTC
README
Inspired by Spring Boot, you can build micro-services in PHP 8 in that style.
Application:
#[WinterBootApplication] class MyApplication { public static function main() { (new WinterWebSwooleApplication())->run(MyApplication::class); } } MyApplication::main();
This framework gives advantage to people already know Spring Boot, and want to jump into PHP8.
- Dependency Injection is managed by the framework with PHP8 Attributes (Annotations)
Sample Service
#[Service] class UserServiceImpl implements UserService { #[Autowired] private PdbcTemplate $pdbc; public function createUser(string $name, string $email) { $this->pdbc->update(/* ... */); } } -------------------------------------------------------------------- #[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); } } # curl command curl "http://localhost/api/v2/users" -d "name=Abc&email=mail"
1. Example Micro-service
Check out the example application here example-service
2. Installation
-
Install PHP 8.0 (or greater)
-
Asynchronous functions #[Async] and #[Scheduled] to work,
swoole
extension needed.
pecl install swoole
Composer
Install framework with composer
composer require suvera/winter-boot composer require suvera/winter-modules
You're Done!
3. Build & Deployment
Framework Support Phing build system
Go through this document Building Service
- Build phar files
- Build Docker Images - See example-service
4. Documentation
- StereoTypes & Dependency Injection
- Configuration
- Logging
- Application Start/Booting
- REST API Development
- Caching
- Custom StereoTypes & Aspect Oriented Magic
- Databases & Transactions
- Actuator
- Locking
- Json and XML
- Async and Scheduling support
- Shared In-Memory Stores
- Daemon Threads
- Building & Deployment
5. Module Extensions
This framework can be extended even further by using https://github.com/suvera/winter-modules
How to create new module
Create a new module by extending WinterModule. Check out below modules for reference
- Doctrine ORM/DBAL Module
- Redis Module
- Apache Kafka Module
- DTCE Module
- S3 Module
- Memdb Module - In-memory databases integrated, such as Apache Ignite, Redis, Memcached, Hazelcast, etc ...
- Service Discovery - Consul, Netflix Eureka, etc...
6. FAQ
1. How to use other framework components in my project?
Yes, any component from any php framework can be used just by composer. Symfony, YII2, Laravel, Code Igniter etc ...
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
Make sure that components are PHP8 compatible.
2. Can I use RoadRunner or Workerman in my project?
Yes, You can extend framework and create core Application runner classes.
Currently, Swoole is done like this.
class WinterWebSwooleApplication extends WinterApplicationRunner implements WinterApplication { }
in the same way that you can also extend framework.
class WinterWebWorkermanApplication extends WinterApplicationRunner implements WinterApplication { } class WinterRoadRunnerApplication extends WinterApplicationRunner implements WinterApplication { }