Getting Started

Welcome to the Mini Framework! This guide will help you get up and running quickly. The framework is lightweight, beginner-friendly, and requires no Composer or external dependencies.

Requirements

  • PHP 8.0 or higher - The framework uses modern PHP features
  • PDO Extension - For database operations
  • Web Server - Apache, Nginx, or PHP built-in server
  • MySQL/MariaDB - For database (optional, if using models)
💡 Note: No Composer, no external dependencies! The framework is completely self-contained.

Installation

Step 1: Download/Clone

Download or clone the framework to your web server directory:

# If using git
git clone https://github.com/Nerajsharma/RouteX.git

# Or download and extract the ZIP file

Step 2: Configure Web Server

Point your web server's document root to the public/ directory:

# Apache VirtualHost example
<VirtualHost *:80>
    ServerName myapp.local
    DocumentRoot /path/to/project/public
    <Directory /path/to/project/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Step 3: Configure Database (Optional)

If you'll be using models, configure your database in config/database.php:


// .env
DB_NAME=mini_framework
DB_USER=root
DB_PASS=

Your First Route

1. Define a Route

Open routes/web.php and add a route:


// routes/web.php
use Core\Route;

Route::get('/', 'HomeController@index');

2. Create a Controller

php mini make:controller HomeController

3. Add Controller Logic


// app/Controllers/HomeController.php
namespace App\Controllers;

use Core\Controller;
use Core\Request;

class HomeController extends Controller
{
    public function index(Request $request)
    {
        return $this->view('home', [
            'title' => 'Welcome',
            'message' => 'Hello, World!'
        ]);
    }
}

4. Create a View


// app/Views/home.php
?>
<!DOCTYPE html>
<html>
<head>
    <title><?php echo $title; ?></title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 p-8">
    <div class="max-w-4xl mx-auto">
        <h1 class="text-4xl font-bold mb-4"><?php echo htmlspecialchars($title); ?></h1>
        <p class="text-xl text-gray-600"><?php echo htmlspecialchars($message); ?></p>
    </div>
</body>
</html>

Running the Application

Development Server

Use the built-in PHP development server:

php mini serve

Then visit http://localhost:8000 in your browser.

Production Server

For production, configure Apache or Nginx to point to the public/ directory.

Next Steps

Now that you have the framework running, explore these topics:

Quick Reference

CLI Commands

  • php mini serve - Start server
  • php mini route:list - List routes
  • php mini make:controller - Create controller
  • php mini make:model - Create model
  • php mini make:middleware - Create middleware

Common Routes

  • Route::get() - GET route
  • Route::post() - POST route
  • Route::middleware() - Add middleware
  • Route::group() - Group routes