https://github.com/jefyokta/oktaax
A php openswoole microframework
https://github.com/jefyokta/oktaax
async-php express micro-framework openswoole-wrapper php php-express php-websocket real-time swoole-framework
Last synced: about 1 month ago
JSON representation
A php openswoole microframework
- Host: GitHub
- URL: https://github.com/jefyokta/oktaax
- Owner: jefyokta
- License: mit
- Created: 2024-09-06T23:23:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-06T07:42:13.000Z (10 months ago)
- Last Synced: 2025-06-14T06:34:19.763Z (10 months ago)
- Topics: async-php, express, micro-framework, openswoole-wrapper, php, php-express, php-websocket, real-time, swoole-framework
- Language: PHP
- Homepage:
- Size: 365 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Oktaax




**Oktaax** is an OpenSwoole HTTP & WebSocket wrapper library. It is designed for developers who want to build high-performance, asynchronous PHP applications.
---
## ⚡ Quick Start
### Requirements
- PHP 8.1+
- Swoole PHP extension
---
### Installation
To install **Oktaax**, use Composer:
```bash
composer require jefyokta/oktaax
```
---
## Hello World HTTP Example
Create a file named `index.php` with the following content:
```php
get("/", function (Request $request, Response $response) {
$response->end("Hello World");
});
$app->listen(3000);
```
Run the server with:
```bash
php index.php
```
Open your browser and navigate to [http://localhost:3000](http://localhost:3000).
---
## 🌐 All-In-One Server
If you need both HTTP and WebSocket support in one class, you can use the `HasWebsocket` trait:
```php
get("/user", function (Request $request, Response $response) {
$response->end("User endpoint hit!");
});
$app->ws('welcome', function (Server $server, Client $client) {
$server->reply($client, "Hi Client {$client->fd}");
});
$app->listen(3000);
```
Run the server as usual:
```bash
php index.php
```
---
## 📡 WebSocket
Here is an example of creating a WebSocket **Channel**:
### Channel
Create a channel class that implements the `Channel` interface.
```php
fd % 2 === 0;
}
}
```
```php
ws('even', function (Server $server, Client $client) {
$server->toChannel(EvenChannel::class)->broadcast(function ($client) {
return "Hello {$client->fd}! You have an even fd!";
});
});
```
---
## HTTP
```php
get("/", fn($request, $response) => $response->end("Welcome to Oktaax"))
->get("/user/{username}", function ($request, $response) {
$user = $request->params['username'];
$response->end("Hello, {$user}");
})
->post("/user", function ($request, $response) {
$data = $request->post;
$response->end("User created with data: " . json_encode($data));
})
->put("/user/{id}", function ($request, $response) {
$id = $request->params['id'];
$response->end("User {$id} updated");
})
->delete("/user/{id}", function ($request, $response) {
$id = $request->params['id'];
$response->end("User {$id} deleted");
});
$app->listen(3000);
```
---
## Trait and Server Options
### ```Oktaax\Oktaax```
is a class that include Requestable and WithBlade traits. You also can get it's instance with function oktaax()