Reputation: 51
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
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]
Upvotes: 1
Views: 1378
Reputation: 6693
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();
Upvotes: 0
Reputation: 3408
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';
Upvotes: 0