Skip to content

Installing Slim Framework for PHP

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.

  • 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.
  1. Download Slim Framework.

    • Visit the official GitHub repository: Slim Framework.
    • Download the latest .zip file.
  2. Extract Files.

    • Unzip the downloaded package on your local computer.
    • You’ll see a folder named Slim-x.y.z (where x.y.z is the version number).
  3. 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_html directory if you want Slim at the root (e.g., example.com).
    • Alternatively, upload to a subdirectory (e.g., example.com/slim).
  4. Create a Test Application.

    • Inside public_html, create a file named slimtest.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();
      ?>
  5. Run the Application.

    • In your browser, go to:

      • http://example.com/slimtest.php/hello/world
    • You should see:

      Hello, world
  6. Adjust Paths if Needed.

    • If you uploaded Slim to a subdirectory, update the require path in slimtest.php accordingly.