I am trying to structure my Slim application like
app
index.php
config
lib
vendor
assets
templates
sys
Slim
and my index.php looks like
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(__FILE__)));
}
if (!defined('ROOT_DIR')) {
define('ROOT_DIR', dirname(dirname(__FILE__)));
}
if (function_exists('ini_set')) {
ini_set('include_path', ROOT_DIR . DS . 'sys' . PATH_SEPARATOR . ini_get('include_path'));
}
require '/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
But can't instanciate Slime object. What I am doing here wrong?
Your path to "require '/Slim/Slim.php'" is wrong.
If you want to load Slim.php from index.php then you need to go one step up (to parent folder) then enter sys directory then Slim and Slim.php is located there. It is important to understand this.
So this should work:
require '../sys/Slim/Slim.php';
Let's understand code: