iviphp / ivi
ivi.php β Simple. Modern. Expressive.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
pkg:composer/iviphp/ivi
Requires
- php: >=8.1
- ext-json: *
- cloudinary/cloudinary_php: ^2
- erusev/parsedown: ^1.7
- firebase/php-jwt: ^6.11
- predis/predis: ^3.0
- symfony/var-dumper: ^7.0
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^10.0
README
Ivi.php
π© Ivi.php β Simple. Modern. Expressive.
βCode with clarity.β
Ivi.php is a modern PHP framework built for developers who value simplicity, speed, and expressive code.
Its minimal core and clean structure make building APIs and web applications a joyful experience.
π Getting Started
Welcome to Ivi.php β a lightweight, modern framework designed to help you build fast and elegant PHP applications.
This guide will walk you through:
- Bootstrapping a new project
- Understanding the folder layout
- Creating your first route, controller, and view
- Connecting to a database with ease
Requirements
- PHP 8.2+
- PDO + driver (e.g.
pdo_mysqlorpdo_sqlite) - Composer
- Recommended:
php -S localhost:8000 -t publicfor local dev
1) Installation
A. Create a project
composer create-project iviphp/ivi my-app
cd my-app
If you cloned the repo directly, run
composer install.
B. Project structure (overview)
. ββ bootstrap/ # app boot strap & helpers ββ config/ # app, routes, database config ββ core/ # ivi.php framework core (Bootstrap, Http, ORM, ...) ββ public/ # web root (index.php) ββ src/ # your application code (Controllers, Models, ...) ββ views/ # PHP templates ββ scripts/ # migrations, seeds, dev scripts ββ docs/ # documentation ββ vendor/
2) First Run
Serve the app:
php -S localhost:8000 -t public
Open: http://localhost:8000
You should see the default page or a basic route response (see next section).
3) Routing
Routes are declared in config/routes.php.
<?php use Ivi\Router\Router; use App\Controllers\HomeController; use App\Controllers\User\UserController; /** @var Router $router */ $router->get('/', function () { return 'Hello ivi.php!'; }); $router->get('/users', [UserController::class, 'index']); $router->get('/users/{id}', [UserController::class, 'show']);
4) Controllers
<?php namespace App\Controllers; use Ivi\Http\Request; use Ivi\Http\HtmlResponse; final class HomeController extends Controller { public function index(Request $request): HtmlResponse { return $this->view('home', [ 'title' => 'Welcome to ivi.php', 'message' => 'Fast & expressive.', ], $request); } }
5) Views
<!-- views/home.php --> <?php $this->layout('base', ['title' => $title ?? 'ivi.php']); ?> <section class="section container"> <h1><?= htmlspecialchars($title ?? 'Welcome') ?></h1> <p><?= htmlspecialchars($message ?? '') ?></p> </section>
Layout example:
<!-- views/base.php --> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title><?= htmlspecialchars($title ?? 'ivi.php') ?></title> <link href="<?= asset('assets/css/app.css') ?>" rel="stylesheet"> <?= $styles ?? '' ?> </head> <body> <nav class="nav"><a href="/">ivi.php</a></nav> <main><?= $this->section('content') ?></main> <?= $scripts ?? '' ?> </body> </html>
6) Markdown Docs
$router->get('/docs', [\App\Controllers\Docs\DocsController::class, 'index']);
View: views/docs/page.php
<section class="docs-hero">
<div class="container">
<h1>Documentation</h1>
<p class="lead">Build fast and expressive apps with <strong>ivi.php</strong>.</p>
</div>
</section>
<main class="docs-content container markdown-body">
<?= $content ?>
</main>
7) Environment & Config
APP_ENV=local APP_DEBUG=true DB_DRIVER=mysql DB_HOST=127.0.0.1 DB_NAME=iviphp DB_USER=root DB_PASS=secret
return [ 'default' => $_ENV['DB_DRIVER'] ?? 'mysql', 'connections' => [ 'mysql' => [ 'driver' => 'mysql', 'host' => $_ENV['DB_HOST'] ?? '127.0.0.1', 'database' => $_ENV['DB_NAME'] ?? 'iviphp', 'username' => $_ENV['DB_USER'] ?? 'root', 'password' => $_ENV['DB_PASS'] ?? '', ], ], ];
8) ORM Quickstart
<?php namespace App\Models; use Ivi\Core\ORM\Model; final class User extends Model { protected string $table = 'users'; }
Usage:
use App\Models\User; $user = User::create(['name' => 'Ada', 'email' => 'ada@example.com']); $found = User::find(1); $found->update(['name' => 'Ada Lovelace']); $found->delete();
9) Migrations CLI
php bin/ivi migrate php bin/ivi migrate:status php bin/ivi migrate:reset
Example SQL:
CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(120), email VARCHAR(190) UNIQUE );
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 Β© 2025 GaspardKirira Authors
Use freely, modify openly, contribute boldly. π
Test Packagist Hook
- hook test Fri Nov 7 08:07:12 PM EAT 2025
- packagist hook test
- packagist hook test