PHPackages                             inphinit/inphinit - 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. inphinit/inphinit

ActiveProject[Framework](/categories/framework)

inphinit/inphinit
=================

A framework for easy creation of routes

2.0.1(1y ago)391318MITPHPPHP &gt;=5.4.0

Since Jun 10Pushed 1mo ago7 watchersCompare

[ Source](https://github.com/inphinit/inphinit)[ Packagist](https://packagist.org/packages/inphinit/inphinit)[ RSS](/packages/inphinit-inphinit/feed)WikiDiscussions 2.x Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (25)Used By (0)

[![Total Downloads](https://camo.githubusercontent.com/954412d4b36e3ee36cf146d8478bb5c679e72907290900ca44d085ee884d0d1c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e7068696e69742f696e7068696e6974)](https://packagist.org/packages/inphinit/inphinit)[![Latest Stable Version](https://camo.githubusercontent.com/bfa5be9095fae30b5683fcd47b781e985ed9c1699a4f97f2f81b79f6d51ad5dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e7068696e69742f696e7068696e6974)](https://packagist.org/packages/inphinit/inphinit)[![License](https://camo.githubusercontent.com/d0c20f8f843a95549c1574780f1791fb0b5a7170d38ff4f7574df14ee94b56fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696e7068696e69742f696e7068696e6974)](https://packagist.org/packages/inphinit/inphinit)

- [Installing](#installing)
- [Testing](#testing)
- [NGINX](#nginx)
- [Folder structure](#folder-structure)
- [Creating routes](#creating-routes)
- [Grouping routes](#grouping-routes)
- [Route and URL patterns](#route-and-url-patterns)
- [Documentation](#documentation)

Installing
----------

[](#installing)

Requirements:

1. Recommended: *PHP 8* (see the currently supported versions at )
    - Minimum: *PHP 5.4* (backward compatibility is preserved for environments with upgrade limitations)
    - If you need a full-featured server on Windows or macOS, consider using WampServer, XAMPP, Laragon, EasyPHP, or AMPPS.
2. (Optional) The Intl PHP extension, required for the `Inphinit\Utility\Strings` class.
3. (Optional) The COM or cURL PHP extension, required for the `Inphinit\Filesystem\Size` class.

After installing PHP, you can install Inphinit via Composer or Git.

To install via Composer, run the command (see more details at ):

```
php composer.phar create-project inphinit/inphinit my-application
```

If Composer is installed globally, use:

```
composer create-project inphinit/inphinit my-application
```

To install via Git:

```
git clone --recurse-submodules https://github.com/inphinit/inphinit.git my-application
cd my-application
```

Testing
-------

[](#testing)

After navigating to your project directory, run the following command to start the [PHP built-in web server](https://www.php.net/manual/en/features.commandline.webserver.php):

```
php -S localhost:5000 -t public index.php
```

Then access it in your browser at `http://localhost:5000/`.

NGINX
-----

[](#nginx)

If you want to use NGINX, you can configure your `nginx.conf` as follows:

```
location / {
    root /home/foo/bar/my-application;

    # Redirect page errors to route system
    error_page 403 /index.php/RESERVED.INPHINIT-403.html;
    error_page 500 /index.php/RESERVED.INPHINIT-500.html;

    try_files /public$uri /index.php?$query_string;

    location = / {
        try_files $uri /index.php?$query_string;
    }

    location ~ /\. {
        try_files /index.php$uri /index.php?$query_string;
    }

    location ~ \.php$ {
        # Replace with your FPM or FastCGI address
        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;
        include fastcgi_params;

        set $teeny_suffix "";

        if ($uri != "/index.php") {
            set $teeny_suffix "/public";
        }

        fastcgi_param SCRIPT_FILENAME $realpath_root$teeny_suffix$fastcgi_script_name;
    }
}

```

> **Note:** For PHP-FPM (FastCGI Process Manager), use `fastcgi_pass unix:/var/run/php/php-fpm.sock` (replace `` with your PHP version).

Folder structure
----------------

[](#folder-structure)

```
├───.htaccess                  # Apache configuration file for handling requests and routing
├───index.php                  # Main entry point; modify constants only if necessary
├───server                     # Shortcut to start the PHP built-in server on Linux or macOS
├───server.bat                 # Shortcut to start the PHP built-in server on Windows
├───web.config                 # IIS configuration file for URL rewriting and routing
├───public/                    # Contains static assets and standalone PHP scripts outside the main app flow
│   └───.htaccess              # Apache configuration for serving static files or standalone scripts
└───system/                    # Contains all application source code and configuration
    ├───dev.php                # Entry point for development mode; runs before main.php
    ├───errors.php             # Handles error pages (e.g., 404, 405) and can render static files or views
    ├───main.php               # Main routing and event definition file for all environments
    ├───boot/                  # Autoload and initialization settings (similar to Composer’s autoload)
    │   ├───importpackages.php # Defines additional package imports for the autoloader
    │   └───namespaces.php     # Maps namespaces to directories for class autoloading
    ├───configs/               # Contains configuration files; avoid committing sensitive data to version control
    │   ├───app.php            # Application configuration; modify existing values as needed
    │   └───debug.php          # Debug configuration; modify existing values as needed
    ├───Controllers/           # Contains controller classes referenced in route definitions
    ├───storage/               # Used for temporary files, logs, or cache data
    ├───vendor/                # Third-party dependencies and the framework core
    └───views/                 # Contains templates and view files
```

In development mode, the `system/dev.php` script is always executed first, followed by `system/main.php`. If an error occurs (e.g., 404 or 405), the last script to run will be `system/errors.php`.

Creating routes
---------------

[](#creating-routes)

To create a new route, edit the `system/main.php` file. If you want the route to be available only in development mode, edit the `system/dev.php` file instead.

The routing system supports *controllers*, [*callables*](https://www.php.net/manual/en/language.types.callable.php), and [*anonymous functions*](https://www.php.net/manual/en/functions.anonymous.php). For example:

```
