Skip to content

Commit b85a5aa

Browse files
committed
Use Absolute Paths
1 parent 3b31bfd commit b85a5aa

5 files changed

Lines changed: 25 additions & 37 deletions

File tree

application/Config/Paths.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Paths
2020
* Include the path if the folder is not in the same directory
2121
* as this file.
2222
*/
23-
public $systemDirectory = 'system';
23+
public $systemDirectory = FCPATH . '../system';
2424

2525
/*
2626
*---------------------------------------------------------------
@@ -35,7 +35,7 @@ class Paths
3535
*
3636
* NO TRAILING SLASH!
3737
*/
38-
public $applicationDirectory = 'application';
38+
public $applicationDirectory = FCPATH . '../application';
3939

4040
/*
4141
* ---------------------------------------------------------------
@@ -48,7 +48,7 @@ class Paths
4848
* for maximum security, keeping it out of the application and/or
4949
* system directories.
5050
*/
51-
public $writableDirectory = 'writable';
51+
public $writableDirectory = FCPATH . '../writable';
5252

5353
/*
5454
* ---------------------------------------------------------------
@@ -61,7 +61,7 @@ class Paths
6161
* for maximum security, keeping it out of the application and/or
6262
* system directories.
6363
*/
64-
public $testsDirectory = 'tests';
64+
public $testsDirectory = FCPATH . '../tests';
6565

6666
/*
6767
* ---------------------------------------------------------------
@@ -75,7 +75,7 @@ class Paths
7575
* can change this to `public_html`, for example, to comply
7676
* with your host's needs.
7777
*/
78-
public $publicDirectory = 'public';
78+
public $publicDirectory = FCPATH;
7979

8080
/*
8181
* ---------------------------------------------------------------
@@ -87,5 +87,5 @@ class Paths
8787
* default this is in `application/Views`. This value
8888
* is used when no value is provided to `Services::renderer()`.
8989
*/
90-
public $viewDirectory = 'application/Views';
90+
public $viewDirectory = FCPATH . '../application/Views';
9191
}

public/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
$paths = new Config\Paths();
3333

3434
// Location of the framework bootstrap file.
35-
$app = require FCPATH . '../' . rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';
35+
$app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';
3636

3737
/*
3838
*---------------------------------------------------------------

spark

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,16 @@ if (substr(php_sapi_name(), 0, 3) === 'cgi')
2929
die("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
3030
}
3131

32-
// Location to the Paths config file.
33-
$pathsPath = 'application/Config/Paths.php';
32+
// Path to the front controller
33+
define('FCPATH', __DIR__ . '/public' . DIRECTORY_SEPARATOR);
3434

3535
// Load our paths config file
36-
require $pathsPath;
37-
$paths = new Config\Paths();
38-
39-
$public = trim($paths->publicDirectory, '/');
36+
require 'application/Config/Paths.php';
4037

41-
// Path to the front controller
42-
define('FCPATH', realpath($public) . DIRECTORY_SEPARATOR);
38+
$paths = new Config\Paths();
4339

4440
// Ensure the current directory is pointing to the front controller's directory
45-
chdir($public);
41+
chdir(FCPATH);
4642

4743
$app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';
4844

system/bootstrap.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,48 +46,44 @@
4646
* so they are available in the config files that are loaded.
4747
*/
4848

49-
$public = trim($paths->publicDirectory, '/');
50-
51-
$pos = strrpos(FCPATH, $public . DIRECTORY_SEPARATOR);
52-
5349
/**
54-
* The path to the main application directory. Just above public.
50+
* The path to the application directory.
5551
*/
56-
if (! defined('ROOTPATH'))
52+
if (! defined('APPPATH'))
5753
{
58-
define('ROOTPATH', substr_replace(FCPATH, '', $pos, strlen($public . DIRECTORY_SEPARATOR)));
54+
define('APPPATH', realpath($paths->applicationDirectory) . DIRECTORY_SEPARATOR);
5955
}
6056

6157
/**
62-
* The path to the application directory.
58+
* The path to the main application directory. Just above APPPATH.
6359
*/
64-
if (! defined('APPPATH'))
60+
if (! defined('ROOTPATH'))
6561
{
66-
define('APPPATH', realpath(ROOTPATH . $paths->applicationDirectory) . DIRECTORY_SEPARATOR);
62+
define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR);
6763
}
6864

6965
/**
7066
* The path to the system directory.
7167
*/
7268
if (! defined('BASEPATH'))
7369
{
74-
define('BASEPATH', realpath(ROOTPATH . $paths->systemDirectory) . DIRECTORY_SEPARATOR);
70+
define('BASEPATH', realpath($paths->systemDirectory) . DIRECTORY_SEPARATOR);
7571
}
7672

7773
/**
7874
* The path to the writable directory.
7975
*/
8076
if (! defined('WRITEPATH'))
8177
{
82-
define('WRITEPATH', realpath(ROOTPATH . $paths->writableDirectory) . DIRECTORY_SEPARATOR);
78+
define('WRITEPATH', realpath($paths->writableDirectory) . DIRECTORY_SEPARATOR);
8379
}
8480

8581
/**
8682
* The path to the tests directory
8783
*/
8884
if (! defined('TESTPATH'))
8985
{
90-
define('TESTPATH', realpath(ROOTPATH . $paths->testsDirectory) . DIRECTORY_SEPARATOR);
86+
define('TESTPATH', realpath($paths->testsDirectory) . DIRECTORY_SEPARATOR);
9187
}
9288

9389
/*

user_guide_src/source/general/common_functions.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ The following constants are always available anywhere within your application.
320320
Core Constants
321321
==============
322322

323-
.. php:const:: ROOTPATH
324-
325-
The path to the main application directory. Just above ``public``.
326-
327323
.. php:const:: APPPATH
328324
329325
The path to the **application** directory.
330326

327+
.. php:const:: ROOTPATH
328+
329+
The path to the main application directory. Just above ``APPPATH``.
330+
331331
.. php:const:: BASEPATH
332332
333333
The path to the **system** directory.
@@ -336,10 +336,6 @@ Core Constants
336336
337337
The path to the directory that holds the front controller.
338338

339-
.. php:const:: SELF
340-
341-
The path to the front controller, **index.php**.
342-
343339
.. php:const:: WRITEPATH
344340
345341
The path to the **writable** directory.

0 commit comments

Comments
 (0)