Get started
Inphinit is a minimalist framework with outstanding performance, designed to promote the use of native PHP functions rather than reinventing the wheel.
System requirements
-
Recommended: PHP 8 (see the currently supported versions at https://www.php.net/supported-versions.php)
- Note: Backward compatible down to PHP 5.4
- (Optional) The Intl PHP extension, required for the
Inphinit\Utility\Stringsclass. - (Optional) The COM or cURL PHP extension, required for the
Inphinit\Filesystem\Sizeclass. - Composer or Git
Install using Composer
If you use composer, run the command (more details in https://getcomposer.org/doc/03-cli.md):
php composer.phar create-project --prefer-dist inphinit/inphinit:^2.1 application
If you use composer global, run the command:
composer create-project --prefer-dist inphinit/inphinit:^2.1 application
Install using Git
If you use Git, for install run this command:
git clone --recurse-submodules -b v2.1.0 https://github.com/inphinit/inphinit.git application
Start a development server
Ater install you can start project using built-in web server
./run serve
Then open http://localhost:5000/ in your web browser.
To customize the host and port, you can use a command like this:
./run serve --host 0.0.0.0 --port 8080
Then open http://localhost:8080/ in your web browser.
Create routes
To create a new route, edit the system/main.php file, if you want the route to only be available in development mode, then edit the system/dev.php file.
The route system supports controllers, callables and anonymous functions, examples:
<?php
// anonymous functions
$app->action('GET', '/closure', function () {
return 'Hello "closure"!';
});
function foobar() {
return 'Hello "function"!';
}
// callable function
$app->action('GET', '/function', 'foobar');
// callable class static method (Note: autoload will include the file)
$app->action('GET', '/class-static-method', ['MyNameSpace\Foo\Bar', 'hello']);
// callable class method
$instance = new Sample();
$app->action('GET', '/class-method', [$instance, 'hello']);
// do not add the Controller prefix, the framework itself will add
Web Servers
Here are basic instructions to configure Inphinit on servers: