Click here to Skip to main content
11,932,681 members (53,568 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked

Slim framework installation

, 6 Aug 2014 CPOL
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) Fulcrum World Wide
India India
No Biography provided

You may also be interested in...

Comments and Discussions

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