System Requirements

System Requirements

  • PHP >= 5.3.0The mcrypt extension is required only if you use encrypted cookies.

Installation

Composer Install

Install composer in your project:

  1. curl -s https://getcomposer.org/installer | php

Create a composer.json file in your project root:

  1. {
  2. "require": {
  3. "slim/slim": "2.*"
  4. }
  5. }

Install via composer:

  1. php composer.phar install

Add this line to your application’s index.php file:

  1. <?php
  2. require 'vendor/autoload.php';

Manual Install

Download and extract the Slim Framework into your project directory and require it in your application’s index.phpfile. You’ll also need to register Slim’s autoloader.

  1. <?php
  2. require 'Slim/Slim.php';
  3. \Slim\Slim::registerAutoloader();

Hello World

Instantiate a Slim application:

  1. $app = new \Slim\Slim();

Define a HTTP GET route:

  1. $app->get('/hello/:name', function ($name) {
  2. echo "Hello, $name";
  3. });

Run the Slim application:

  1. $app->run();