Skip to content
Related Articles

Related Articles

Improve Article

Slim Framework | Installation and Configuration

  • Last Updated : 16 Apr, 2020

Slim is a lightweight, easy to use and fast PHP framework used to develop the powerful website quickly with ease. Like other PHP frameworks, slim also supports routers, middlewares, bodyparser, page templates, encrypted cookies and much more.

Prerequisites:

  1. PHP installation on windows
  2. Environment Setup To Run the Project
  3. Composer Software to install slim

Installation:

  1. Go to your directory where XAMPP is installed and open htdocs folder. (In my case it is C:\xampp\htdocs).
  2. Open command prompt and nevigate to current working directory as your current directory.
  3. Enter the command
    mkdir project_name && cd project_name

    This command will create a project folder with project_name and set the present working directory to it.

  4. Now enter the command
    composer require slim/slim:3.* 

    (Here 3.* refers to version number)
    This will install the slim framework in the current directory.

  5. Now enter the command
    notepad index.php

    and click on yes. It will create a new file index.php and will open it for editing.

  6. Now type the following code in the file




    <?php
      
    require 'vendor/autoload.php';
      
    $app = new \Slim\App;
    $app->get('/', function () {
      echo 'Welcome to my slim app';
    });
    $app->run();
    ?>

    It is the code for our first slim application.

  7. Save the file and close it.
  8. Open xampp control panel and run the apache server.
  9. Now open a web browser and go to url -> http://localhost:81/project_name/
    As you can see our first app is running on the server successfully.

    You have successfully installed slim and have created your first app with that.
My Personal Notes arrow_drop_up
Recommended Articles
Page :