Skip to content

Getting Started

Guilherme Nascimento edited this page Jun 11, 2018 · 12 revisions

Server requirements

Installing

You can use composer, after composer installed navigate to server folder (if using Apache, Nginx or IIS):

  • If using server in Unix-like eg. cd /var/www
  • Xampp eg. cd c:/xampp/htdocs
  • Wamp eg. cd c:/wamp/www

Perform composer for create a new project (replace [project_name] by folder name, like blog):

composer create-project inphinit/inphinit [project_name]

If is not global you can use:

php composer.phar create-project inphinit/inphinit [project_name]

Navigate to [project_name] using explorer, finder or terminal, like this:

cd [project_name]

Note: for install using GIT or for contributors: Install using GIT

If is not using Apache, Nginx or IIS your can try server built-in using server.bat or server.sh. If you use Windows edit the server.bat and change PHP_BIN and PHP_INI variables:

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

To start use double click in server.bat or type in cmd/PowerShell like this and press Enter:

C:\Users\User> server.bat

If using Unix-like edit PHP_BIN and PHP_INI (you may need to replace bash path #!/bin/bash):

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

In terminal type this:

$ ./server.sh

Configuration

In index.php has 3 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 thing you need is INPHINIT_COMPOSER, if true you are using composer, if false you are using inphinit-autoload (this is recommended for being faster and more efficient)

In ./system/application/Config/config.php you have 3 main variables:

'appdata_expires' => 86400, //Used to temporary files in ./system/storage/temp folder
'development'     => true,  //Define if project is configured to development or production server
'maintenance'     => false  //Disabled Routes and 'ready' event if `true`

In ./system/dev.php you can perform events, functions and create routes available only for development server, for example show error in a View:

<?php

use Inphinit\Experimental\Debug;

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

It is not necessary to adjust the error_reporting or display_errors, the framework already configures it according to the type of environment.

Apache

After create your project in Apache folder (eg. /var/www, c:/wamp/www, c:/xampp/htdcos, etc) access in your browser this address http://localhost/[project_name]/generate-htaccess.php (replace [project_name] by folder project name), if using production navigate to http://example/generate-htaccess.php or other machine in your network navigate to IP server, example http://10.0.0.20/generate-htaccess.php. No needs copy output from web-browser .htaccess has already been generated.

Nginx

You can navigate to http://localhost/[project_name]/generate-ngix.php or use cmd or PowerShell (CLI), in project folder perform this command:

php generate-nginx.php

After copy the output contents and edit nginx.conf in Nginx folder, for more details see https://www.nginx.com/resources/wiki/start/topics/examples/full/

Testing server

To simplify checking the server requirements cited in Server requirements, you can navigate to http://localhost/[project_name]/check.php

Clone this wiki locally