Skip to content

Getting started

Stein Janssen edited this page Feb 24, 2016 · 3 revisions

Step 1 - .htaccess file
create an .htaccess file in the root of your project and fill it with the code below:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Step 2 - require szenis/routing
In your terminal execute: composer require szenis/routing 0.*

Step 3 - create index.php
Create the file index.php in the root of your project

Step 4 - require autoload.php
Require vendor/autoload.php in your index.php

Step 5 - use Router
Add

use Szenis\Router;
use Szenis\RouteResolver;

to your index.php

Step 6 *optional
For debuging purpose add the following to your index.php

error_reporting(E_ALL);
ini_set('display_errors', 1);
Clone this wiki locally