2016-03-02 99 views
1

您好我是新的超薄框架,並在後端使用超薄框架,並使用客戶端,AngularJS時從服務器加載數據,這下面的錯誤顯示:無法打開需要修身/ Slim.php

Fatal error: require(): Failed opening required 'Slim/slim.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ngelgir0/public_html/api/index.php on line 3

這裏是我的文件夾結構:

public_html/ 
    - api 
    + Slim 
    index.php 
    .htaccess 

enter image description here

這裏是在index.php第幾行:

<?php 
require 'Slim/Slim.php'; 
\Slim\Slim::registerAutoloader(); 
$app = new Slim(); 

// endpoints related with FeedbackFormsResource 
$app->get('/feedbacks', 'getFeedbackForms'); 
$app->get('/feedbacks/:id', 'getFeedbackFormsById'); 
$app->get('/feedbacks/search/:query', 'findFeedbackForm'); 
$app->post('/feedbacks/', 'addFeedbackForm'); 
$app->put('/feedbacks/:id', 'updateFeedbackForm'); 
$app->delete('/feedbacks/:id', 'deleteFeedbackForm'); 

而這就是我對.htaccess文件:

RewriteEngine On 
RewriteBase /api/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php [QSA,L] 
+0

把API目錄以外的.htaccess文件(中的public_html /) – Vigikaran

+0

我沒有,但沒有工作,同樣的錯誤顯示 –

+0

請幫我試試不行 –

回答

0

你的截圖說,錯誤位於api/index.php
如果你在那個index.php裏有require Slim/slim.php Slim文件夾必須在api之內。

爲了解決這個問題做了

require '../Slim/Slim.php'; 
0

您可以隨時使用define它引用您的文件根目錄以供將來參考。如果您需要包含,則不需要上傳或下載../的目錄。

define('FILE_ROOT', dirname(__FILE__).'/'); 
require_once FILE_ROOT.'Slim/Slim.php'; 

來獲得當前目錄和工作,你可以使用:

getcwd();