Live stream set for 2025-08-04 at 14:00:00 Eastern
Ask questions in the live chat about any programming or lifestyle topic.
This livestream will be on YouTube or you can watch below.
Getting Started with Flight PHP: MVC and MariaDB Integration Made Easy
Welcome to your first Flight PHP tutorial! Flight is a fast, simple, and extensible micro-framework for PHP that enables you to build web apps and APIs quickly—perfect for beginners and experienced developers alike.
The framework has been actively revived, with community contributions restoring features like route groups, middleware, and a simple database wrapper while maintaining compatibility with v2 apps. See the official docs at docs.flightphp.com and source code at github.com/flightphp/core.
In this beginner’s guide, we will:
- Install Flight PHP v3.17.0 via Composer
- Set up a minimal MVC app
- Connect to a MariaDB database and render a list of users
1. Installing Flight PHP v3.17.0 Using Composer
In your project directory, run the following commands:
composer require flightphp/core:3.17.0
This installs version 3.17.0, released July 20, 2025. PHP 7.4+ is required.
2. Creating a Simple MVC Structure
Use the following structure for your application:
project/
│-- controllers/
│ └-- HomeController.php
│-- models/
│ └-- UserModel.php
│-- views/
│ └-- users.php
└-- index.php
Routing & Bootstrapping (index.php
)
<?php require 'vendor/autoload.php'; require 'controllers/HomeController.php'; require 'models/UserModel.php'; Flight::set('flight.views.path', 'views'); Flight::route('/', [new HomeController(), 'index']); Flight::start();
3. Model Layer (models/UserModel.php
)
<?php class UserModel { private PDO $db; public function __construct(PDO $pdo) { $this->db = $pdo; } public function getAllUsers(): array { $stmt = $this->db->query("SELECT * FROM users"); return $stmt->fetchAll(PDO::FETCH_ASSOC); } }
4. Controller Layer (controllers/HomeController.php
)
<?php class HomeController { public function index() { $pdo = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); $model = new UserModel($pdo); $users = $model->getAllUsers(); Flight::render('users', ['users' => $users]); } }
5. View Layer (views/users.php
)
<!DOCTYPE html> <html> <head><meta charset="utf-8"><title>User List</title></head> <body> <h1>User List</h1> <ul> <?php foreach ($users as $user): ?> <li><?= htmlspecialchars($user['name']) ?> (<?= htmlspecialchars($user['email']) ?>)</li> <?php endforeach; ?> </ul> </body> </html>
Recommended Database Schema
CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), email VARCHAR(100) ); INSERT INTO users (name, email) VALUES ('Alice Smith', 'alice@example.com'), ('Bob Jones', 'bob@example.com');
MVC Support Overview
While Flight PHP does not enforce a full MVC directory structure, it fully supports MVC-style routing and templating through Flight::route()
and Flight::render()
. You can organize your application easily using these features. Learn more in the Flight PHP Docs.
📷 Screenshots & Screencast






📚 Further Resources & Services
- Book: Learning PHP by Edward Ojambo — A complete beginner’s guide. Buy on Amazon
- Course: Learning PHP video course. Enroll here
- 1-on-1 Tutorials: Need help or migrating from other PHP Framework? Contact me for personalized support
Conclusion
Flight PHP v3.17.0 is a lightweight and modern micro-framework that gives you everything you need to build efficient MVC applications. With support for MariaDB and clean routing, it’s a perfect choice for new developers and rapid prototyping.
Need help with forms, API development, or custom routing? Let me know—I offer professional support and tutorials to help you succeed.