Download the PHP package mohammadraufzahed/tondbad-swoole without Composer
On this page you can find all versions of the php package mohammadraufzahed/tondbad-swoole. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mohammadraufzahed/tondbad-swoole
More information about mohammadraufzahed/tondbad-swoole
Files in mohammadraufzahed/tondbad-swoole
Package tondbad-swoole
Short Description Tondbād - A lightweight and high-performance PHP framework built on OpenSwoole with routing, job workers, queue management, and gRPC support.
License MIT
Informations about the package tondbad-swoole
TondbadSwoole
TondbadSwoole is a high-performance, lightweight PHP framework built on OpenSwoole for creating asynchronous web applications, microservices, and gRPC servers. It offers a robust routing system, dependency injection, and support for gRPC, making it an ideal choice for modern PHP applications.
Features
- Asynchronous HTTP Server powered by OpenSwoole.
- FastRoute based routing system with attribute-based route definitions.
- Dependency Injection using a custom container for managing services and configurations.
- gRPC Support for building high-performance microservices.
- Monolog Integration for comprehensive logging to console and files.
- Graceful Shutdown to handle system signals (SIGTERM, SIGINT) and ensure smooth termination.
Requirements
- PHP 8.2 or higher
- OpenSwoole extension
- Composer
Installation
-
Clone the repository:
-
Install dependencies using Composer:
-
Install OpenSwoole:
- Configure the environment:
- Create a
.env
file in the root directory and configure necessary settings. For example:
- Create a
Usage
Running the HTTP Server
To start the HTTP server, run the following command:
This will start the OpenSwoole server on the configured port (default: 8000
).
Running the gRPC Server
To start the gRPC server, use the command:
This will start the gRPC server for handling gRPC requests.
Defining Routes
Routes can be defined using PHP 8 attributes within your controllers. Here is an example of a route definition using the
#[Endpoint]
attribute:
Registering Routes
In your configuration file (config/routes.php
), list the classes containing route definitions:
Logging
TondbadSwoole uses Monolog for logging:
- Logs are written to the console (
php://stdout
) and stored in a file (logs/app.log
). - You can configure the logging settings in the
LoggerServiceProvider
.
Log Levels
The default log level is DEBUG
, capturing all levels of logs. You can change this level in the logger configuration.
Graceful Shutdown
The server will gracefully shut down on receiving SIGINT
(Ctrl+C
) or SIGTERM
signals, allowing ongoing requests to
complete before stopping the server.
Compilation of Protocol Buffers (for gRPC)
To compile .proto
files, run the following command:
This command will generate the necessary PHP files for gRPC communication.
Coming Soon
- Background Job Processing: The next version will include support for background job processing using OpenSwoole's TaskWorker, allowing you to handle long-running tasks efficiently in the background.
- Queue Management: Enhanced queue management for dispatching and handling background tasks.
Contributing
Feel free to submit issues or pull requests to improve this project. Contributions are welcome!
License
This project is licensed under the MIT License.
All versions of tondbad-swoole with dependencies
ext-openswoole Version *
nikic/fast-route Version ^2.0@dev
monolog/monolog Version ^3.0@dev
grpc/grpc Version dev-master
google/protobuf Version dev-master
openswoole/core Version ^22.1.5
openswoole/grpc Version dev-master
openswoole/ide-helper Version dev-master