Click here to Skip to main content
13,091,920 members (61,716 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 6 Aug 2014

Slim framework installation

, 6 Aug 2014
Rate this:
Please Sign up or sign in to vote.
How to install Slim Framework on Ubuntu?


Slim is a tiny PHP framework that helps you quickly developing simple and powerful web applications and web services.


  • Slim is very simple and easy to configure.
  • Slim is used to rendering template with custom views.
  • Slim supports flash messaging.
  • It's also stored HTTP caching.
  • Slim app should encrypt its HTTP cookies.
  • Slim supports the concept of modes.
  • Slim will use to built-in error handler if debugging is enable.


Composer Install

Simple way is to download and extract the Slim Framework into your project directory and require it in your application’s index.php file.

Using the code

You need to give 777 -R permissions to your project folder.

Install composer:

curl -s | php

Install via composer:

composer install
php composer.phar install

You also need to register Slim’s autoloader.

require 'Slim/Slim.php';

Make sure you required Slim.php file that belongs to in Slim folder. Otherwise you won't be able to use Slim framework.

Then invoke this static registerAutoloader() function define into the Slim class. It is necessary to registerAutoloader() function if you won't register nothing will be work.


The next step would be just need to instantiate the \Slim\Slim() class and use referrence as an object, use that object in our code.

$application = new \Slim\Slim();

Define a HTTP GET route:

function ($first,$last){
echo "Hi!! $first $last";

'/hi/:firstname/:lastname' is the URL. If this URL is match then following function will be invoked using GET HTTP method.

function ($first,$last){
echo "Hi!! $first $last";

Run the your Slim application:


The URL address like


helloslim.php is my Slim application page.

hi/Bryan/Adams append with the URL address if it would be match to hi/:firstname/:lastname and if it's available the generate the output using passing parameters $first and $last.

Output is,

Hi!! Bryan Adams

Using Slim is very simple. For Advanced knowledge, You can refer following links.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Latika surse
Software Developer (Senior)
India India
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170813.1 | Last Updated 6 Aug 2014
Article Copyright 2014 by Latika surse
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid