PHPackages                             ody/framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ody/framework

ActiveLibrary[API Development](/categories/api)

ody/framework
=============

ODY framework

0.2.0(1y ago)015MITPHPPHP &gt;=8.3

Since Mar 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ody-dev/framework)[ Packagist](https://packagist.org/packages/ody/framework)[ RSS](/packages/ody-framework/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (9)Used By (0)

ODY Framework Documentation
===========================

[](#ody-framework-documentation)

Introduction
------------

[](#introduction)

ODY is a modern PHP API framework built with a focus on high performance and modern architecture. It leverages Swoole's coroutines for asynchronous processing, follows PSR standards for interoperability, and provides a clean architecture for building robust APIs.

Installation
------------

[](#installation)

### Requirements

[](#requirements)

- PHP 8.3 or higher
- Swoole PHP extension (≥ 6.0.0)
- Composer

### Basic Installation

[](#basic-installation)

```
composer create-project ody/framework your-project-name
cd your-project-name
php ody publish

php ody server:start
```

Configuration
-------------

[](#configuration)

Configuration files are stored in the `config` directory. The primary configuration files include:

- `app.php`: Application settings, service providers, and middleware
- `database.php`: Database connections configuration
- `logging.php`: Logging configuration and channels
- `cache.php`: Cache configuration

Environment-specific configurations can be set in `.env` files. A sample `.env.example` file is provided that you can copy to `.env` and customize:

```
cp .env.example .env
```

Project Structure
-----------------

[](#project-structure)

```
your-project/
├── app/                  # Application code
│   ├── Controllers/      # Controller classes
│   └── ...
├── config/               # Configuration files
├── public/               # Public directory (web server root)
│   └── index.php         # Application entry point
├── routes/               # Route definitions
│   └── api.php           # API routes
├── src/                  # Framework core components
├── storage/              # Storage directory for logs, cache, etc.
├── tests/                # Test files
├── vendor/               # Composer dependencies
├── .env                  # Environment variables
├── .env.example          # Environment variables example
├── composer.json         # Composer package file
├── ody                   # CLI entry point
└── README.md             # Project documentation

```

Routing
-------

[](#routing)

Routes are defined in the `routes` directory. The framework supports various HTTP methods and route patterns:

```
// Basic route definition
Route::get('/hello', function (ServerRequestInterface $request, ResponseInterface $response) {
    return $response->json([
        'message' => 'Hello World'
    ]);
});

// Route with named controller
Route::post('/users', 'App\Controllers\UserController@store');

// Route with middleware
Route::get('/users/{id}', 'App\Controllers\UserController@show')
    ->middleware('auth');

// Route groups
Route::group(['prefix' => '/api/v1', 'middleware' => ['throttle:60,1']], function ($router) {
    $router->get('/status', function ($request, $response) {
        return $response->json([
            'status' => 'operational'
        ]);
    });
});
```

Controllers
-----------

[](#controllers)

Controllers handle the application logic and are typically stored in the `app/Controllers` directory:

```
