1
votes

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:

public_html/
    - api
    + Slim
    index.php
    .htaccess

enter image description here

And here is the first few lines in 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');

And this is what I have for .htaccess file:

RewriteEngine On
RewriteBase /api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
2
put .htaccess file outside api directory (in public_html/) - Vigikaran
i did but not work and same error show - Ali Mousapour
please help me i try not work - Ali Mousapour
please check the file name require 'Slim/Slim.php'; in the screenshot i could see the file name looks "slim.php" it should be "Slim.php" - Vigikaran
tanks for answer Vigikaran but name is true before cheked name - Ali Mousapour

2 Answers

0
votes

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';
0
votes

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:

getcwd();