diff --git a/application/Config/Paths.php b/application/Config/Paths.php index c58f91a1ad..f679dca50d 100644 --- a/application/Config/Paths.php +++ b/application/Config/Paths.php @@ -6,7 +6,7 @@ * Modifying these allows you to re-structure your application, * share a system folder between multiple applications, and more. * - * All paths are relative to the application's front controller, index.php + * All paths are relative to the project's root folder. */ class Paths { @@ -19,7 +19,7 @@ class Paths * Include the path if the folder is not in the same directory * as this file. */ - public $systemDirectory = '../system'; + public $systemDirectory = 'system'; /* *--------------------------------------------------------------- @@ -34,7 +34,7 @@ class Paths * * NO TRAILING SLASH! */ - public $applicationDirectory = '../application'; + public $applicationDirectory = 'application'; /* * --------------------------------------------------------------- @@ -47,7 +47,7 @@ class Paths * for maximum security, keeping it out of the application and/or * system directories. */ - public $writableDirectory = '../writable'; + public $writableDirectory = 'writable'; /* * --------------------------------------------------------------- @@ -60,7 +60,7 @@ class Paths * for maximum security, keeping it out of the application and/or * system directories. */ - public $testsDirectory = '../tests'; + public $testsDirectory = 'tests'; /* * --------------------------------------------------------------- diff --git a/public/index.php b/public/index.php index 1de1832983..79964f681d 100644 --- a/public/index.php +++ b/public/index.php @@ -1,13 +1,12 @@ systemDirectory,DIRECTORY_SEPARATOR) . '/bootstrap.php'; +// Location of the framework bootstrap file. +// This is the second of two lines that might need to be changed, depending on your folder structure. +$app = require FCPATH . '../system//bootstrap.php'; /* *--------------------------------------------------------------- diff --git a/system/Commands/Utilities/Namespaces.php b/system/Commands/Utilities/Namespaces.php new file mode 100644 index 0000000000..8210ead6dc --- /dev/null +++ b/system/Commands/Utilities/Namespaces.php @@ -0,0 +1,123 @@ +psr4 as $ns => $path) + { + $path = realpath($path) ?? $path; + + $tbody[] = [ + $ns, + realpath($path) ?? $path, + is_dir($path) ? "Yes" : "MISSING" + ]; + } + + $thead = ['Namespace', 'Path', 'Found?']; + + CLI::table($tbody, $thead); + } + +} diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php new file mode 100644 index 0000000000..d103abbb65 --- /dev/null +++ b/system/Commands/Utilities/Routes.php @@ -0,0 +1,126 @@ +getRoutes($method); + + foreach ($routes as $from => $to) + $tbody[] = [ + $from, + $method, + $to + ]; + } + + $thead = ['Route', 'Method', 'Command']; + + CLI::table($tbody, $thead); + } + +} diff --git a/system/Router/Router.php b/system/Router/Router.php index b5080a7993..7eedc65636 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -361,7 +361,9 @@ class Router implements RouterInterface { $routes = $this->collection->getRoutes($this->collection->getHTTPVerb()); - $uri = ltrim($uri, '/ '); + $uri = $uri == '/' + ? $uri + : ltrim($uri, '/ '); // Don't waste any time if (empty($routes)) diff --git a/system/bootstrap.php b/system/bootstrap.php index 0afe18ae87..04dc9f5e04 100644 --- a/system/bootstrap.php +++ b/system/bootstrap.php @@ -63,7 +63,7 @@ if (! defined('ROOTPATH')) */ if (! defined('APPPATH')) { - define('APPPATH', realpath($paths->applicationDirectory).DIRECTORY_SEPARATOR); + define('APPPATH', realpath(ROOTPATH . $paths->applicationDirectory).DIRECTORY_SEPARATOR); } /** @@ -71,7 +71,7 @@ if (! defined('APPPATH')) */ if (! defined('BASEPATH')) { - define('BASEPATH', realpath($paths->systemDirectory).DIRECTORY_SEPARATOR); + define('BASEPATH', realpath(ROOTPATH . $paths->systemDirectory).DIRECTORY_SEPARATOR); } /** @@ -79,7 +79,7 @@ if (! defined('BASEPATH')) */ if (! defined('WRITEPATH')) { - define('WRITEPATH', realpath($paths->writableDirectory).DIRECTORY_SEPARATOR); + define('WRITEPATH', realpath(ROOTPATH . $paths->writableDirectory).DIRECTORY_SEPARATOR); } /** @@ -87,7 +87,7 @@ if (! defined('WRITEPATH')) */ if (! defined('TESTPATH')) { - define('TESTPATH', realpath($paths->testsDirectory).DIRECTORY_SEPARATOR); + define('TESTPATH', realpath(ROOTPATH . $paths->testsDirectory).DIRECTORY_SEPARATOR); } /* diff --git a/tests/feature/HomeTest.php b/tests/feature/HomeTest.php index 82a822ab15..46a4ffcc9e 100644 --- a/tests/feature/HomeTest.php +++ b/tests/feature/HomeTest.php @@ -2,6 +2,11 @@ use CodeIgniter\Test\FeatureTestCase; +/** + * This relies on a database connection + * + * @codeCoverageIgnore + */ class HomeTest extends FeatureTestCase { public function testCanLoadPage() diff --git a/tests/system/Test/FeatureTestCaseTest.php b/tests/system/Test/FeatureTestCaseTest.php index 12b08908de..89f4395f6d 100644 --- a/tests/system/Test/FeatureTestCaseTest.php +++ b/tests/system/Test/FeatureTestCaseTest.php @@ -3,8 +3,12 @@ use CodeIgniter\Test\FeatureTestCase; use CodeIgniter\Test\FeatureResponse; +/** + * @group DatabaseLive + */ class FeatureTestCaseTest extends FeatureTestCase { + public function setUp() { parent::setUp(); @@ -16,8 +20,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['add', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->call('get', 'home'); @@ -32,8 +36,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['get', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->get('home'); @@ -45,8 +49,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['post', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->post('home'); @@ -57,8 +61,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['put', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->put('home'); @@ -69,8 +73,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['patch', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->patch('home'); @@ -81,8 +85,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['options', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->options('home'); @@ -93,8 +97,8 @@ class FeatureTestCaseTest extends FeatureTestCase { $this->withRoutes([ ['delete', 'home', function() { - return 'Hello World'; - }] + return 'Hello World'; + }] ]); $response = $this->delete('home'); diff --git a/user_guide_src/source/general/configuration.rst b/user_guide_src/source/general/configuration.rst index c62545d1e9..af63b1b05d 100644 --- a/user_guide_src/source/general/configuration.rst +++ b/user_guide_src/source/general/configuration.rst @@ -74,10 +74,8 @@ needs with empty or dummy data. In each environment, you can then copy the file appropriate data. When your application runs, this file will be automatically loaded and the variables will be put into -the environment. This will work in any environment except for production, where the variables should be -set in the environment through whatever means your getServer supports, such as .htaccess files, etc. These -variables are then available through ``getenv()``, ``$_SERVER``, and ``$_ENV``. Of the three, ``getenv()`` function -is recommended since it is not case-sensitive:: +the environment. This will work in any environment. These variables are then available through ``getenv()``, +``$_SERVER``, and ``$_ENV``. Of the three, ``getenv()`` function is recommended since it is not case-sensitive:: $s3_bucket = getenv('S3_BUCKET'); $s3_bucket = $_ENV['S3_BUCKET']; diff --git a/writable/cache/.htaccess b/writable/cache/.htaccess old mode 100644 new mode 100755 diff --git a/writable/cache/index.html b/writable/cache/index.html old mode 100644 new mode 100755 diff --git a/writable/debugbar/.gitkeep b/writable/debugbar/.gitkeep old mode 100644 new mode 100755 diff --git a/writable/logs/.htaccess b/writable/logs/.htaccess old mode 100644 new mode 100755 diff --git a/writable/logs/index.html b/writable/logs/index.html old mode 100644 new mode 100755 diff --git a/writable/uploads/index.html b/writable/uploads/index.html old mode 100644 new mode 100755