2016-03-02 11:34
浏览 81

打开所需的Slim / Slim.php失败

Hi I am new in slim framework and using Slim framework in backend and using AngularJS in client, when load data from server this following error show:

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

Here is my folder structure:

    - api
    + Slim

enter image description here

And here is the first few lines in index.php:

require 'Slim/Slim.php';
$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');

And this is what I have for .htaccess file:

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

图片转代码服务由CSDN问答提供 功能建议

嗨我是瘦身框架的新手,在后端使用Slim框架,在客户端使用AngularJS,从服务器加载数据时 以下错误显示:

致命错误:require():无法打开所需的'Slim / slim.php'(include_path ='。:/ usr / lib / php :/ us / local / lib / php')在第3行的/home/ngelgir0/public_html/api/index.php中


  public_html / 
  -  api 
 + Slim 

以下是< code> index.php

require'Tlim / Slim.php'; 
  \ Slim \ Slim :: registerAutoloader(); 
 $ app = new Slim(); 
 $ app-&gt; get('/ feedbacks','getFeedbackForms'); \  n $ app-&gt; get('/ feedbacks::id','getFeedbackFor  msById'); 
 $ app-&gt; get('/ feedbacks / search /:query','findFeedbackForm'); 
 $ app-&gt; post('/ feedbacks /','addFeedbackForm'); 
  $ app-&gt; put('/ feedbacks /:id','updateFeedbackForm'); 
 $ app-&gt; delete('/ feedbacks /:id','deleteFeedbackForm'); 

这就是我对 .htaccess 文件所拥有的:

  RewriteEngine On 
RewriteBase / api / 
RewriteCond  %{REQUEST_FILENAME}!-f 
RewriteRule ^(。*)$ index.php [QSA,L] 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanpang2751 2016-03-03 14:34

    Your screenshot says that the error is located in api/index.php.
    If you have require Slim/slim.php inside that index.php that Slim folder must be inside api.

    To fix that do a

    require '../Slim/Slim.php';
    解决 无用
    打赏 举报
  • douhuan6065 2016-03-03 15:19

    You can always use a define which references your file root for future reference. If you ever need to include, you won't need to go up or down directories with the ../.

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

    to get the current directory and work with that you can use:

    解决 无用
    打赏 举报

相关推荐 更多相似问题