iviphp/ivi

Ivi.php is a fast, lightweight, and modular PHP framework with expressive routing, built-in ORM, caching, and WebSocket support—ideal for modern APIs and SPAs.

Maintainers

Package info

github.com/iviphp/ivi

Type:project

pkg:composer/iviphp/ivi

Statistics

Installs: 47

Dependents: 0

Suggesters: 0

Stars: 16

Open Issues: 11

v1.6.1 2026-04-23 19:32 UTC

README

Ivi.php

Build backend systems with clarity.

Ivi.php is a modern PHP framework designed for developers who want a clean structure, predictable behavior, and fast development without unnecessary complexity.

Overview

Ivi.php is a modern PHP framework designed for building APIs and web applications with clarity and control.

It provides a minimal core with a consistent architecture, allowing developers to build production-ready systems without unnecessary complexity.

The framework focuses on:

  • predictable structure
  • explicit behavior
  • fast development cycles
  • real-world features out of the box

Installation

composer create-project iviphp/ivi my-app
cd my-app

Run the application:

ivi serve

Quick Example

use Ivi\Core\Bootstrap\App;
use Ivi\Http\Request;

$app = new App(__DIR__);

$app->router->get('/', fn() => ['hello' => 'ivi.php']);

$app->router->post('/echo', fn(Request $req) => [
    'you_sent' => $req->json()
]);

$app->run();

Routing

$app->router->get('/users', fn() => ['users' => []]);

$app->router->get('/user/{name}', function (array $params) {
    return ['name' => $params['name']];
});

Request Handling

$app->router->post('/data', function (Request $req) {
    return [
        'json' => $req->json(),
        'all'  => $req->all()
    ];
});

Views

use Ivi\Core\View\View;

$app->router->get('/', function () {
    return View::make('home', [
        'title'   => 'Welcome',
        'message' => 'Ivi.php running'
    ]);
});

Validation

use Ivi\Core\Validation\Validator;

$input = [
    'email'    => 'user@example.com',
    'password' => 'secret123'
];

$validated = (new Validator($input, [
    'email'    => 'required|email',
    'password' => 'required|min:6'
]))->validate();

Update scenario:

$post = ['password' => ''];

if (trim($post['password']) === '') {
    unset($post['password']);
}

$validated = (new Validator($post, [
    'password' => 'sometimes|min:6'
]))->validate();

ORM

Model

use Ivi\Core\ORM\Model;

final class User extends Model
{
    protected static array $fillable = ['name', 'email', 'password', 'active'];
}

CRUD

$user = User::create([
    'name'  => 'Alice',
    'email' => 'alice@example.com'
]);

$found = User::find(1);

$found->fill(['name' => 'Updated'])->save();

$found->delete();

Query Builder

$users = User::query()
    ->where('status = ?', 'active')
    ->orderBy('id DESC')
    ->limit(5)
    ->get();

$count = User::query()
    ->where('status = ?', 'active')
    ->count();

Repository Pattern

use Ivi\Core\ORM\Repository;

final class UserRepository extends Repository
{
    protected function modelClass(): string
    {
        return User::class;
    }

    public function findByEmail(string $email): ?User
    {
        $row = User::query()->where('email = ?', $email)->first();
        return $row ? new User($row) : null;
    }
}

JWT Authentication

use Ivi\Core\Jwt\JWT;

$jwt = new JWT();

$token = $jwt->generate([
    'sub' => 123
], [
    'key'      => 'secret',
    'alg'      => 'HS256',
    'validity' => 3600
]);

$jwt->check($token, ['key' => 'secret']);

Logging

log_info("Application started");

log_error("Database error", "Database");

log_debug([
    'user_id' => 1
], "Debugging");

Features:

  • daily log rotation
  • JSON support
  • trace mode
  • automatic log directory creation

Collections

$v = vector([1, 2, 3]);
$v->push(4);

$m = hashmap(['name' => 'Ivi']);
$m->put('version', '1.0');

$s = hashset(['apple']);
$s->add('banana');

$t = str(" hello ")->trim()->upper();

CLI

Ivi.php provides a built-in CLI for development and deployment.

Project

ivi new my-app

Database

ivi migrate
ivi migrate:status
ivi migrate:reset
ivi seed

Modules

ivi make:module Blog
ivi modules:publish-assets

Development

ivi serve
ivi test
ivi coverage

Deployment

ivi deploy

Project Structure

.
├── bootstrap/
├── config/
├── core/
├── public/
├── src/
├── views/
├── scripts/
├── docs/
└── vendor/

Configuration

Example .env:

APP_ENV=local
APP_DEBUG=true

DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_NAME=iviphp
DB_USER=root
DB_PASS=secret

Philosophy

Ivi.php is built around a simple idea:

  • keep the core minimal
  • expose real capabilities
  • avoid hidden magic
  • favor explicit code over abstraction

Documentation

https://iviphp.com/docs

Download

https://github.com/iviphp/ivi

git clone https://github.com/iviphp/ivi.git
cd ivi
composer install

License

10) Validation

use Ivi\Http\Request;
use Ivi\Validation\Validator;

$validator = Validator::make($request->all(), [
  'name' => 'required|min:2|max:120',
  'email' => 'required|email',
]);

if ($validator->fails()) {
  return response()->json(['errors' => $validator->errors()], 422);
}

11) Responses

use Ivi\Http\JsonResponse;
use Ivi\Http\HtmlResponse;

return new JsonResponse(['ok' => true]);
return new HtmlResponse('<h1>Hello</h1>');

12) Production Tips

  • Set APP_ENV=production
  • Use APP_DEBUG=false
  • Configure opcache
  • Serve from public/
  • Minify assets

Happy building with ivi.php 🚀

⚖️ License

MIT License © 2026 Gaspard Kirira