Open In App

Slim Framework | Installation and Configuration

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

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 navigate to current working directory as your current directory.
  3. Enter the command
mkdir project_name && cd project_name
  1. This command will create a project folder with project_name and set the present working directory to it.
  2. Now enter the command
composer require slim/slim:3.* 
  1. (Here 3.* refers to version number) This will install the slim framework in the current directory.
  2. Now enter the command
notepad index.php
  1. and click on yes. It will create a new file index.php and will open it for editing.
  2. Now type the following code in the file 

CPP




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


  1. It is the code for our first slim application.
  2. Save the file and close it.
  3. Open xampp control panel and run the apache server.
  4. 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.

Last Updated : 10 May, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads