Get started
Learn how to create a new Inphinit project.
Introduction
Inphinit is a minimalist framework with incredible performance, focused mainly on encouraging the use of native PHP functions, the goal is to not need to reinvent the wheel, unlike others. Read more in About Inphinit.
System requirements
- PHP 8 (minimum 5.4, but it is recommended that you use PHP 8)
- Multibyte String (GD also) (optional, only used in
Inphinit\Utility\Strings
class) - iconv (optional, only used in
Inphinit\Utility\Strings
class) - fileinfo (optional, only used in
Inphinit\Filesystem\File
) - COM or cURL (optional, only used in
Inphinit\Filesystem\Size(Size::COM)
andInphinit\Filesystem\Size(Size::CURL)
) - Composer or Git (optional, see download options)
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
cd application
If you use composer global, run the command:
composer create-project --prefer-dist inphinit/inphinit:^2.1 application
cd 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
cd application
Download
As an alternative to Composer and Git, you can download the zip, then extract it on your machine. Downloadable formats:
See example for download using terminal
wget "https://foo/inphinit-v2.1.0.tar.gz"
tar -xf inphinit-v2.1.0.tar.gz
cd application
Start a development server
Ater install you can start project using built-in web server
php -S localhost:5000 -t public index.php
Then open http://localhost:5000/
in your web browser.
For unix-like there is the shortcut ./server
, you can configure it following the instructions in server file and for Windows you can use server.bat
, you can configure it following the instructions in server.bat file.
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
$app->action('GET', '/controller', 'Boo\Bar::xyz');
Web Servers
Here are basic instructions to configure Inphinit on servers: