mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge branch 'refactor/directories' into testing/log
This commit is contained in:
commit
7118d89070
@ -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';
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
// Location to the Paths config file.
|
||||
// This should be the only line you need to
|
||||
// edit in this file.
|
||||
$pathsPath = '../application/Config/Paths.php';
|
||||
|
||||
// Path to the front controller (this file)
|
||||
define('FCPATH', __DIR__.DIRECTORY_SEPARATOR);
|
||||
|
||||
// Location of the Paths config file.
|
||||
// This is the first of two lines that might need to be changed, depending on your folder structure.
|
||||
$pathsPath = FCPATH . '../application/Config/Paths.php';
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* BOOTSTRAP THE APPLICATION
|
||||
@ -24,7 +23,9 @@ chdir(__DIR__);
|
||||
require $pathsPath;
|
||||
$paths = new Config\Paths();
|
||||
|
||||
$app = require rtrim($paths->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';
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
|
123
system/Commands/Utilities/Namespaces.php
Normal file
123
system/Commands/Utilities/Namespaces.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php namespace CodeIgniter\Commands\Utilities;
|
||||
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014-2018 British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author CodeIgniter Dev Team
|
||||
* @copyright 2014-2018 British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
*/
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use Config\Autoload;
|
||||
|
||||
/**
|
||||
* Lists namespaces set in Config\Autoload with their
|
||||
* full server path. Helps you to verify that you have
|
||||
* the namespaces setup correctly.
|
||||
*
|
||||
* @package CodeIgniter\Commands
|
||||
*/
|
||||
class Namespaces extends BaseCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* The group the command is lumped under
|
||||
* when listing commands.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The Command's name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'namespaces';
|
||||
|
||||
/**
|
||||
* the Command's short description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Verifies your namespaces are setup correctly.';
|
||||
|
||||
/**
|
||||
* the Command's usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'namespaces';
|
||||
|
||||
/**
|
||||
* the Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* the Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Displays the help for the spark cli script itself.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$config = new Autoload();
|
||||
|
||||
$tbody = [];
|
||||
foreach ($config->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);
|
||||
}
|
||||
|
||||
}
|
126
system/Commands/Utilities/Routes.php
Normal file
126
system/Commands/Utilities/Routes.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php namespace CodeIgniter\Commands\Utilities;
|
||||
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014-2018 British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*RouRouddfdf
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author CodeIgniter Dev Team
|
||||
* @copyright 2014-2018 British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
*/
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use Config\Autoload;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Lists all of the user-defined routes. This will include any Routes files
|
||||
* that can be discovered, but will NOT include any routes that are not defined
|
||||
* in a routes file, but are instead discovered through auto-routing.
|
||||
*
|
||||
* @package CodeIgniter\Commands
|
||||
*/
|
||||
class Routes extends BaseCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* The group the command is lumped under
|
||||
* when listing commands.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The Command's name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'routes';
|
||||
|
||||
/**
|
||||
* the Command's short description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Displays all of user-defined routes. Does NOT display auto-detected routes.';
|
||||
|
||||
/**
|
||||
* the Command's usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'routes';
|
||||
|
||||
/**
|
||||
* the Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [];
|
||||
|
||||
/**
|
||||
* the Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Displays the help for the spark cli script itself.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$collection = Services::routes(true);
|
||||
$methods = ['get', 'head', 'post', 'put', 'delete', 'options', 'trace', 'connect', 'cli'];
|
||||
|
||||
$tbody = [];
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
$routes = $collection->getRoutes($method);
|
||||
|
||||
foreach ($routes as $from => $to)
|
||||
$tbody[] = [
|
||||
$from,
|
||||
$method,
|
||||
$to
|
||||
];
|
||||
}
|
||||
|
||||
$thead = ['Route', 'Method', 'Command'];
|
||||
|
||||
CLI::table($tbody, $thead);
|
||||
}
|
||||
|
||||
}
|
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
use CodeIgniter\Test\FeatureTestCase;
|
||||
|
||||
/**
|
||||
* This relies on a database connection
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class HomeTest extends FeatureTestCase
|
||||
{
|
||||
public function testCanLoadPage()
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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'];
|
||||
|
0
writable/cache/.htaccess
vendored
Normal file → Executable file
0
writable/cache/.htaccess
vendored
Normal file → Executable file
0
writable/cache/index.html
vendored
Normal file → Executable file
0
writable/cache/index.html
vendored
Normal file → Executable file
0
writable/debugbar/.gitkeep
Normal file → Executable file
0
writable/debugbar/.gitkeep
Normal file → Executable file
0
writable/logs/.htaccess
Normal file → Executable file
0
writable/logs/.htaccess
Normal file → Executable file
0
writable/logs/index.html
Normal file → Executable file
0
writable/logs/index.html
Normal file → Executable file
0
writable/uploads/index.html
Normal file → Executable file
0
writable/uploads/index.html
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user