Help Needed- Class 'Slim\Slim' Not Found Error

Hey everyone,

I’m pretty new to Slim and just started working on a project using Slim Framework. I’m running into an issue and could really use some help from the community.

I’m getting the following error:

Class 'Slim\Slim' not found

When I was searching about this, I came across to these resources/articles Fatal error: Class 'Slim\App' not found Salesforce Journey Builder php - Class 'Slim\Slim' not found with composer - Stack Overflow and as per them I’ve double-checked my code and everything seems fine to me, but obviously, I’m missing something. Here’s a bit more context:

  • I installed Slim via Composer with the following command: composer require slim/slim
  • I included the autoload file like this: require 'vendor/autoload.php';

Here is a snippet of my code:

<?php
require 'vendor/autoload.php';

$app = new Slim\Slim();

$app->get('/', function () {
    echo 'Hello, world!';
});

$app->run();

I’m not sure what I’m doing wrong. Any ideas or suggestions would be greatly appreciated! Thanks in advance!

Best Regards,

The Slim App class should be: Slim\App

Slim also needs a Http Package.

Please read the documentation where you can find more information how to setup a new Slim app.

You can find the installation documentation of v4, here:
https://www.slimframework.com/docs/v4/start/installation.html