Slim Framework is a lightweight PHP micro‑framework that helps you quickly build web applications and APIs. While some frameworks are available via Softaculous, Slim requires manual installation on your hosting account.
Why Use Slim Framework?
-
Minimalist design, ideal for RESTful APIs.
-
Easy to learn and extend with middleware.
-
Supports routing, dependency injection, and PSR standards.
-
Lightweight and fast compared to larger frameworks.
Steps to Install Slim Framework (Manual)
-
Download Slim Framework.
-
Visit the official GitHub repository: Slim Framework.
-
Download the latest
.zipfile.
-
-
Extract Files.
-
Unzip the downloaded package on your local computer.
-
You’ll see a folder named
Slim-x.y.z(wherex.y.zis the version number).
-
-
Upload Files to Your Hosting Account.
-
Use FTP or File Manager in cPanel to upload the contents of the extracted folder.
-
Place them in the
public_htmldirectory if you want Slim at the root (e.g.,example.com). -
Alternatively, upload to a subdirectory (e.g.,
example.com/slim).
-
-
Create a Test Application.
-
Inside
public_html, create a file namedslimtest.php. -
Add the following sample code:
<?php require 'Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); $app->get('/hello/:name', function ($name) { echo "Hello, $name"; }); $app->run(); ?>
-
-
Run the Application.
-
In your browser, go to:
-
http://example.com/slimtest.php/hello/world
-
-
You should see:
Hello, world
-
-
Adjust Paths if Needed.
-
If you uploaded Slim to a subdirectory, update the
requirepath inslimtest.phpaccordingly.
-
Notes
|