PHPackages                             arefshojaei/routex - 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. [Framework](/categories/framework)
4. /
5. arefshojaei/routex

ActiveProject[Framework](/categories/framework)

arefshojaei/routex
==================

A minimal PHP framework for base file routing

1.1.1(2w ago)23MITPHPPHP ^8.0

Since Jun 16Pushed 2w agoCompare

[ Source](https://github.com/ArefShojaei/Routex)[ Packagist](https://packagist.org/packages/arefshojaei/routex)[ RSS](/packages/arefshojaei-routex/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

🚀 Routex - PHP File-based Routing Framework
===========================================

[](#-routex---php-file-based-routing-framework)

[![PHP Version](https://camo.githubusercontent.com/aff0b1ebd8bae48ba12ef0b1128d6460084232cd88d6e102969df5f5eea3b35a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e302d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![GitHub](https://camo.githubusercontent.com/33cfe401e185427739b89613ea7cc4a05aaf547cdc57e4e41f56ba73a2f0ef6b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d526f757465782d626c61636b3f6c6f676f3d676974687562)](https://github.com/ArefShojaei/Routex)

A lightweight and modern PHP framework with **file-based routing** inspired by Next.js, designed around the MVC architecture and developer-friendly CLI tools.

Build fast PHP applications with automatic routing, controllers, models, views, and custom commands.

[![Routex](https://private-user-images.githubusercontent.com/134844185/608590686-95536577-b33b-48b2-a901-8b2d5afdc9dd.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e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JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcxMlQxMzIyMjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xN2ZjODFkNjY1NDVlODhkYjBhZmFhODJhNmRmZmU3Y2IyY2ExMDMwNWQ4YjI1MTU0ODQ0MWNjY2EyOWY4NmUyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.OEMY3a3VLTwcV_cwbtal649950Vor9ye6W0Eee0GGu8)---

✨ Features
----------

[](#-features)

- 🗂️ **File-based Routing** - Create routes using the file system structure
- ⚡ **Dynamic Routes** - Support for parameterized routes like `/products/:id`
- 🏗️ **MVC Architecture** - Organized structure with Models, Controllers, and Views
- 🧩 **Controller Injection** - Connect views to controllers seamlessly
- 🖥️ **Built-in Development Server** - Run your application with a simple CLI command
- 🔧 **Custom CLI Commands** - Extend your application with your own console commands
- 📦 **Composer Support** - Easy installation and dependency management
- 🪶 **Lightweight &amp; Fast** - Minimal core with zero unnecessary complexity

---

🛣️ File-based Routing
=====================

[](#️-file-based-routing)

Routex automatically converts your `pages/` directory into application routes.

Example:

```
pages/
│
├── index.php                 → /
├── about.php                 → /about
│
├── auth/
│   ├── login.php             → /auth/login
│   └── register.php          → /auth/register
│
├── products/
│   ├── index.php             → /products
│   └── [id].php              → /products/:id
│
└── admin/
    └── [id]/
        └── dashboard.php     → /admin/:id/dashboard
```

---

🏗️ Project Structure (MVC)
==========================

[](#️-project-structure-mvc)

```
Routex/
│
├── app/
│   ├── Console/
│   │   └── Commands/
│   │
│   ├── Controllers/
│   └── Models/
│
├── config/
│   ├── app.php
│   └── database.php
│
├── pages/                    # Views
│   └── index.php
│
├── public/
│   ├── assets/
│   └── index.php
│
├── vendor/
├── cli
├── composer.json
└── README.md
```

---

📥 Installation &amp; Setup
==========================

[](#-installation--setup)

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Composer

---

Install using Composer
----------------------

[](#install-using-composer)

```
composer create-project arefshojaei/routex my-app
```

Move into your project:

```
cd my-app
```

---

Clone from GitHub
-----------------

[](#clone-from-github)

```
git clone https://github.com/ArefShojaei/Routex.git
cd Routex
```

Install dependencies:

```
composer install
```

---

🚀 Running the Application
=========================

[](#-running-the-application)

Routex comes with a built-in PHP development server.

### Default

[](#default)

```
php cli serve
```

### Custom Host

[](#custom-host)

```
php cli serve --host:0.0.0.0
```

### Custom Port

[](#custom-port)

```
php cli serve --port:3000
```

### Custom Host &amp; Port

[](#custom-host--port)

```
php cli serve --host:0.0.0.0 --port:3000
```

After running the server, open:

```
http://localhost:8000
```

---

🧠 MVC Usage
===========

[](#-mvc-usage)

📦 Model
-------

[](#-model)

**File:** `app/Models/Product.php`

```

    Product Page

```

---

💻 Custom CLI Commands (Optional)
================================

[](#-custom-cli-commands-optional)

Create your own commands inside:

```
app/Console/Commands/
```

Example:

```
