Fatal error: Uncaught Error: Class 'Slim\Slim' not found

Fatal error: Uncaught Error: Class 'Slim\Slim' not found

这是我的摘录 index.php 我安装了 composer,但我一直收到 class sim not found.

<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim(array(
    'templates.path' => '../templates'
));

$app->get('/api', function () use ($app) {
    // Get the start and end timestamps from request query parameters
    $startTimestamp = $app->request->get('start');
    $endTimestamp = $app->request->get('end');

    try {
        // Open database connection
        $conn = new \PDO('mysql:host=127.0.0.1;dbname=calendar', 'root', '');

        // Query database for events in range
        $stmt = $conn->prepare('SELECT * FROM events WHERE start >= FROM_UNIXTIME(:start) AND end < FROM_UNIXTIME(:end) ORDER BY start ASC');
        $stmt->bindParam(':start', $startTimestamp, \PDO::PARAM_INT);
        $stmt->bindParam(':end', $endTimestamp, \PDO::PARAM_INT);
        $stmt->execute();

        // Fetch query results 
        $results = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        // Return query results as JSON
        echo json_encode($results);
    } catch (\PDOException $e) {
        $app->halt(500, $e->getMessage());
   }
});
$app->get('/', function () use ($app) {
    $app->render('calendar.html');
});
$app->run();
?>

我做错了什么?我正在尝试实施完整日历 jquery 插件

1 - 您可以验证已安装的软件包 composer info -i

2 - 看来你做了个小技巧 new \Slim\Slim

尝试

$app = new \Slim\App(array(
    'templates.path' => '../templates'
));