What is "inphinit"

Server requirements

  • PHP 5.3.0+
  • Multibyte String (GD probably too) (optional, only required if using Inphinit\Helper::toAscii)
  • libiconv (optional, only required if using Inphinit\Helper::toAscii)
  • fileinfo (optional, only required if using Inphinit\File::mime)
  • Apache or Nginx or IIS for production environment

Installing

First install the commiserate if not, then navigate to the folder where your projects are located via terminal/cmd:

  • If you are using a Unix-like server you should probably access it like this cd /var/www
  • If it’s Xampp it must be something like cd c:/xampp/htdocs
  • If it’s Wamp it must be something like cd c:/wamp/www
  • If using the built-in server choose the place you want

Then in the terminal/cmd execute the following command (swap [nome do projeto] by the name you want the folder to have, an example would be blog):

composer create-project inphinit/inphinit [nome do projeto]

If Composer is not globally installed use like this:

php composer.phar create-project inphinit/inphinit [nome do projeto]

Then browse to the folder [nome do projeto] by the explorer (Windows) or Finder (Mac OSX) or Terminal, thus:

cd [nome do projeto]

If you are not using Apache, Nginx or IIS you can use the built-in server with server.bat or server.sh. If it is Windows edit the server.bat and change the values of the variables PHP_BIN and PHP_INI by the way of installing your PHP:

set PHP_BIN="C:\php\php.exe"
set PHP_INI="C:\php\php.ini"
set HOST_PORT=9000

To start the server just double-click server.bat or type in CMD or Powershell this (press Enter after):

C:\Users\User> server.bat

If your system is Unix-like (Linux, BSB, Mac OSX) edit variables PHP_BIN and PHP_INI (depending on the system you may have to change the bash path in #!/bin/bash):

#!/bin/bash
PHP_BIN="/usr/bin/php"
PHP_INI="/etc/php5/cli/php.ini"
HOST_PORT=9000

In the terminal type this:

$ ./server.sh

Settings

In the index.php there are 4 constants:

define('INPHINIT_START', microtime(true));
define('INPHINIT_ROOT', rtrim(strtr(dirname(__FILE__), '\\', '/'), '/') . '/');
define('INPHINIT_PATH', INPHINIT_ROOT . 'system/');
define('INPHINIT_COMPOSER', false);

The only one you’ll need to adjust INPHINIT_COMPOSER, be defined true you will use Composer-autoload, if false you will the inphinit-autoload (this is most recommended for being faster and more efficient)

In the ./system/application/Config/config.php there are 3 variables:

'appdata_expires' => 86400, //Usado para definir o tempo de vida limite dos arquivos na pasta ./system/storage/temp
'developer'      => true,  //Define se o ambiente é de produção ou desenvolvimento
'maintenance'    => false  //Se `true` irá desativar as Routas e o evento 'ready'

In the archive ./system/dev.php you can add events, functions and create routes that will only be available in the development environment, an example for a View to display errors that occur:

<?php

use Inphinit\Experimental\Debug;

Debug::view('error', 'debug.error');

No need to configure error_reporting or display_errors manually, the framework sets this up by itself depending on the type of environment you are in

Apache

After creating your project in the Apache folder (example: /var/www, c:/wamp/www, c:/xampp/htdcos, etc), access this address in your web browser http://localhost/[nome do projeto]/generate-htaccess.php (change [nome do projeto] by the name you typed at the time of installing via).

If you are in "production" you can navigate to something like http://meu-site.com/generate-htaccess.php or is on another machine on the same network browse the IP http://10.0.0.20/generate-htaccess.php. This will generate the .htaccess adapted to the current server, it is not necessary to copy the generated content on the screen, if you are in a production environment you can delete the generate-htaccess.php.

Nginx

Navigate to this address http://localhost/[nome do projeto]/generate-ngix.php or access your Terminal, CMD or Powershell (CLI), if you are in production you can do this through SSH, then navigate to the folder where your project is located:

cd /var/www

And then type in:

php generate-nginx.php

The content generated or via browser as per via CLI must be copied to your clipboard (Ctrl+C) for example

And then you must edit the file nginx.conf in the Nginx folder, for more details see https://www.nginx.com/resources/wiki/start/topics/examples/full/

IIS and IIS Express

If you use IIS or IIS Express for production and want to develop in a similar environment you can follow the guidelines in PHP with IIS

Testing your server

To simplify checking the requirements described at the beginning you can access the check.php via HTTP, for example http://localhost/[nome do projeto]/check.php

More details on: https://github.com/inphinit/inphinit/wiki