Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';t实例化细长对象_Php_Slim - Fatal编程技术网

Php Can';t实例化细长对象

Php Can';t实例化细长对象,php,slim,Php,Slim,我正在尝试使用Slim为AngularJS应用程序创建一个RESTful API。我刚开始鳕鱼,我已经有问题了。我只是想实例化Slim,但它告诉我: 致命错误:未捕获错误:在第10行的/home/kevdug/webapps/angularjs/api/index.php中找不到类“Slim\App”。php:10堆栈跟踪:#0{main}抛出/home/kevdug/webapps/angularjs/api/index.php 我有一个“api”目录,其中有我的“index.php”文件和一

我正在尝试使用Slim为AngularJS应用程序创建一个RESTful API。我刚开始鳕鱼,我已经有问题了。我只是想实例化Slim,但它告诉我:

致命错误:未捕获错误:在第10行的/home/kevdug/webapps/angularjs/api/index.php中找不到类“Slim\App”。php:10堆栈跟踪:#0{main}抛出/home/kevdug/webapps/angularjs/api/index.php

我有一个“api”目录,其中有我的“index.php”文件和一个“vendor”文件夹(安装Slim时由composer生成的文件夹)

这是我的index.php文件:

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

    if (file_exists('vendor/autoload.php')) {
        echo "The file $filename exists";
    } else {
        echo "The file $filename does not exist";
    }

    $app = new \Slim\App();
    //$app = new Slim();

    //$app->run();

    ?>

我的代码确实告诉我aitoload.php文件存在


奇怪的是,我完全遵循Slim网站上的示例…

嗯。。。。。。。。。。。。。。原来我只是个白痴,我不需要在应用程序后面加括号:

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

$app = new \Slim\App;

$app->run();

?>

井。。。。。。。。。。。。。。原来我只是个白痴,我不需要在应用程序后面加括号:

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

$app = new \Slim\App;

$app->run();

?>