diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 7a095b937fe6..f5e3d20e453e 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -42,6 +42,9 @@ class CLI * Is the readline library on the system? * * @var bool + * + * @deprecated 4.4.2 Should be protected. + * @TODO Fix to camelCase in the next major version. */ public static $readline_support = false; @@ -49,6 +52,9 @@ class CLI * The message displayed at prompts. * * @var string + * + * @deprecated 4.4.2 Should be protected. + * @TODO Fix to camelCase in the next major version. */ public static $wait_msg = 'Press any key to continue...'; @@ -63,6 +69,8 @@ class CLI * Foreground color list * * @var array + * + * @TODO Fix to camelCase in the next major version. */ protected static $foreground_colors = [ 'black' => '0;30', @@ -88,6 +96,8 @@ class CLI * Background color list * * @var array + * + * @TODO Fix to camelCase in the next major version. */ protected static $background_colors = [ 'black' => '40', diff --git a/tests/system/Commands/RoutesTest.php b/tests/system/Commands/RoutesTest.php index 059ce964d5e0..9cd24cbe0f6b 100644 --- a/tests/system/Commands/RoutesTest.php +++ b/tests/system/Commands/RoutesTest.php @@ -198,46 +198,28 @@ public function testRoutesCommandRouteLegacy(): void $routes->loadRoutes(); $routes->setAutoRoute(true); - $namespace = 'Tests\Support\Controllers'; - $routes->setDefaultNamespace($namespace); command('routes'); $expected = <<<'EOL' - +---------+-------------------------------+---------------+-----------------------------------------------------+----------------+---------------+ - | Method | Route | Name | Handler | Before Filters | After Filters | - +---------+-------------------------------+---------------+-----------------------------------------------------+----------------+---------------+ - | GET | / | » | \App\Controllers\Home::index | | toolbar | - | GET | closure | » | (Closure) | | toolbar | - | GET | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | HEAD | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | POST | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | PUT | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | DELETE | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | OPTIONS | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | TRACE | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | CONNECT | testing | testing-index | \App\Controllers\TestController::index | | toolbar | - | CLI | testing | testing-index | \App\Controllers\TestController::index | | | - | auto | hello | | \Tests\Support\Controllers\Hello::index | | toolbar | - | auto | hello/index[/...] | | \Tests\Support\Controllers\Hello::index | | toolbar | - | auto | newautorouting/getIndex[/...] | | \Tests\Support\Controllers\Newautorouting::getIndex | | toolbar | - | auto | newautorouting/postSave[/...] | | \Tests\Support\Controllers\Newautorouting::postSave | | toolbar | - | auto | popcorn | | \Tests\Support\Controllers\Popcorn::index | | toolbar | - | auto | popcorn/index[/...] | | \Tests\Support\Controllers\Popcorn::index | | toolbar | - | auto | popcorn/pop[/...] | | \Tests\Support\Controllers\Popcorn::pop | | toolbar | - | auto | popcorn/popper[/...] | | \Tests\Support\Controllers\Popcorn::popper | | toolbar | - | auto | popcorn/weasel[/...] | | \Tests\Support\Controllers\Popcorn::weasel | | toolbar | - | auto | popcorn/oops[/...] | | \Tests\Support\Controllers\Popcorn::oops | | toolbar | - | auto | popcorn/goaway[/...] | | \Tests\Support\Controllers\Popcorn::goaway | | toolbar | - | auto | popcorn/index3[/...] | | \Tests\Support\Controllers\Popcorn::index3 | | toolbar | - | auto | popcorn/canyon[/...] | | \Tests\Support\Controllers\Popcorn::canyon | | toolbar | - | auto | popcorn/cat[/...] | | \Tests\Support\Controllers\Popcorn::cat | | toolbar | - | auto | popcorn/json[/...] | | \Tests\Support\Controllers\Popcorn::json | | toolbar | - | auto | popcorn/xml[/...] | | \Tests\Support\Controllers\Popcorn::xml | | toolbar | - | auto | popcorn/toindex[/...] | | \Tests\Support\Controllers\Popcorn::toindex | | toolbar | - | auto | popcorn/echoJson[/...] | | \Tests\Support\Controllers\Popcorn::echoJson | | toolbar | - | auto | remap[/...] | | \Tests\Support\Controllers\Remap::_remap | | toolbar | - +---------+-------------------------------+---------------+-----------------------------------------------------+----------------+---------------+ + +---------+------------------+---------------+----------------------------------------+----------------+---------------+ + | Method | Route | Name | Handler | Before Filters | After Filters | + +---------+------------------+---------------+----------------------------------------+----------------+---------------+ + | GET | / | » | \App\Controllers\Home::index | | toolbar | + | GET | closure | » | (Closure) | | toolbar | + | GET | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | HEAD | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | POST | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | PUT | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | DELETE | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | OPTIONS | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | TRACE | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | CONNECT | testing | testing-index | \App\Controllers\TestController::index | | toolbar | + | CLI | testing | testing-index | \App\Controllers\TestController::index | | | + | auto | / | | \App\Controllers\Home::index | | toolbar | + | auto | home | | \App\Controllers\Home::index | | toolbar | + | auto | home/index[/...] | | \App\Controllers\Home::index | | toolbar | + +---------+------------------+---------------+----------------------------------------+----------------+---------------+ EOL; $this->assertStringContainsString($expected, $this->getBuffer()); } diff --git a/user_guide_src/source/changelogs/v4.4.2.rst b/user_guide_src/source/changelogs/v4.4.2.rst index c956964fa9ea..55cf33b0df25 100644 --- a/user_guide_src/source/changelogs/v4.4.2.rst +++ b/user_guide_src/source/changelogs/v4.4.2.rst @@ -32,6 +32,8 @@ Deprecations - **Filters:** The Auto-Discovery for Filters and ``Filters::discoverFilters()`` is deprecated. Use :ref:`registrars` instead. See :ref:`modules-filters` for details. +- **CLI:** The public property ``CLI::$readline_support`` and ``CLI::$wait_msg`` + are deprecated. These methods will be protected. Bugs Fixed ********** diff --git a/user_guide_src/source/installation/upgrade_440.rst b/user_guide_src/source/installation/upgrade_440.rst index 76bcc2957a68..c84d72a7e1fe 100644 --- a/user_guide_src/source/installation/upgrade_440.rst +++ b/user_guide_src/source/installation/upgrade_440.rst @@ -91,7 +91,7 @@ When Passing Classname with Namespace to Factories The behavior of passing a classname with a namespace to Factories has been changed. See :ref:`ChangeLog ` for details. -If you have code like ``model('\Myth\Auth\Models\UserModel::class')`` or +If you have code like ``model(\Myth\Auth\Models\UserModel::class)`` or ``model('Myth\Auth\Models\UserModel')`` (the code may be in the third-party packages), and you expect to load your ``App\Models\UserModel``, you need to define the classname to be loaded before the first loading of that class:: diff --git a/user_guide_src/source/tutorial/create_news_items.rst b/user_guide_src/source/tutorial/create_news_items.rst index 2388841b70b8..6443e674d450 100644 --- a/user_guide_src/source/tutorial/create_news_items.rst +++ b/user_guide_src/source/tutorial/create_news_items.rst @@ -26,6 +26,23 @@ You can read more about the CSRF protection in :doc:`Security <../libraries/secu because :ref:`auto-routing-legacy` permits any HTTP method to access a controller. Accessing the controller with a method you don't expect could bypass the filter. +Adding Routing Rules +******************** + +Before you can start adding news items into your CodeIgniter application +you have to add an extra rule to **app/Config/Routes.php** file. Make sure your +file contains the following: + +.. literalinclude:: create_news_items/004.php + +The route directive for ``'news/new'`` is placed before the directive for ``'news/(:segment)'`` to ensure that the form to create a news item is displayed. + +The ``$routes->post()`` line defines the router for a POST request. It matches +only a POST request to the URI path **/news**, and it maps to the ``create()`` method of +the ``News`` class. + +You can read more about different routing types in :ref:`defined-route-routing`. + Create a Form ************* @@ -151,23 +168,6 @@ never need to do that, since it is an auto-incrementing field in the database. This helps protect against Mass Assignment Vulnerabilities. If your model is handling your timestamps, you would also leave those out. -Adding Routing Rules -******************** - -Before you can start adding news items into your CodeIgniter application -you have to add an extra rule to **app/Config/Routes.php** file. Make sure your -file contains the following: - -.. literalinclude:: create_news_items/004.php - -The route directive for ``'news/new'`` is placed before the directive for ``'news/(:segment)'`` to ensure that the form to create a news item is displayed. - -The ``$routes->post()`` line defines the router for a POST request. It matches -only a POST request to the URI path **/news**, and it maps to the ``create()`` method of -the ``News`` class. - -You can read more about different routing types in :ref:`defined-route-routing`. - Create a News Item ****************** diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst index 183b2f0c8570..935f79476054 100644 --- a/user_guide_src/source/tutorial/news_section.rst +++ b/user_guide_src/source/tutorial/news_section.rst @@ -120,6 +120,17 @@ that are going to display the news items to the user. This could be done in our ``Pages`` controller created earlier, but for the sake of clarity, a new ``News`` controller is defined. +Adding Routing Rules +==================== + +Modify your **app/Config/Routes.php** file, so it looks as follows: + +.. literalinclude:: news_section/008.php + +This makes sure the requests reach the ``News`` controller instead of +going directly to the ``Pages`` controller. The second ``$routes->get()`` line +routes URI's with a slug to the ``show()`` method in the ``News`` controller. + Create News Controller ====================== @@ -200,17 +211,6 @@ The only thing left to do is create the corresponding view at .. literalinclude:: news_section/007.php -Adding Routing Rules -******************** - -Modify your **app/Config/Routes.php** file, so it looks as follows: - -.. literalinclude:: news_section/008.php - -This makes sure the requests reach the ``News`` controller instead of -going directly to the ``Pages`` controller. The second ``$routes->get()`` line -routes URI's with a slug to the ``show()`` method in the ``News`` controller. - Point your browser to your "news" page, i.e., **localhost:8080/news**, you should see a list of the news items, each of which has a link to display just the one article. diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst index 9745cbb633de..db3382245195 100644 --- a/user_guide_src/source/tutorial/static_pages.rst +++ b/user_guide_src/source/tutorial/static_pages.rst @@ -9,13 +9,51 @@ Static Pages :doc:`installed the framework <../installation/index>` in your development environment. -The first thing you're going to do is set up a **controller** to handle -static pages. A controller is simply a class that helps delegate work. -It is the glue of your web application. +The first thing you're going to do is set up routing rules to handle static pages. + +Setting Routing Rules +********************* + +Routing associates a URI with a controller's method. A controller is simply a +class that helps delegate work. We will create a controller later. + +Let's set up routing rules. Open the routes file located at **app/Config/Routes.php**. + +The only route directive there to start with should be: + +.. literalinclude:: static_pages/003.php + +This directive says that any incoming request without any content +specified should be handled by the ``index()`` method inside the ``Home`` controller. + +Add the following lines, **after** the route directive for ``'/'``. + +.. literalinclude:: static_pages/004.php + :lines: 2- + +CodeIgniter reads its routing rules from top to bottom and routes the +request to the first matching rule. Each rule is a regular expression +(left-side) mapped to a controller and method name +(right-side). When a request comes in, CodeIgniter looks for the first +match, and calls the appropriate controller and method, possibly with +arguments. + +More information about routing can be found in the :doc:`../incoming/routing`. + +Here, the second rule in the ``$routes`` object matches a GET request +to the URI path **/pages**, and it maps to the ``index()`` method of the ``Pages`` class. + +The third rule in the ``$routes`` object matches a GET request to a URI segment +using the placeholder ``(:segment)``, and passes the parameter to the +``view()`` method of the ``Pages`` class. Let's Make our First Controller ******************************* +The next thing you're going to do is set up a **controller** to handle +static pages. A controller is simply a class that helps delegate work. +It is the glue of your web application. + Create Pages Controller ======================= @@ -141,42 +179,6 @@ view. throw errors on case-sensitive platforms. You can read more about it in :doc:`../outgoing/views`. -Setting Routing Rules -********************* - -We have made the controller. The next thing is to set routing rules. -Routing associates a URI with a controller's method. - -Let's do that. Open the routes file located at **app/Config/Routes.php**. - -The only route directive there to start with should be: - -.. literalinclude:: static_pages/003.php - -This directive says that any incoming request without any content -specified should be handled by the ``index()`` method inside the ``Home`` controller. - -Add the following lines, **after** the route directive for ``'/'``. - -.. literalinclude:: static_pages/004.php - :lines: 2- - -CodeIgniter reads its routing rules from top to bottom and routes the -request to the first matching rule. Each rule is a regular expression -(left-side) mapped to a controller and method name -(right-side). When a request comes in, CodeIgniter looks for the first -match, and calls the appropriate controller and method, possibly with -arguments. - -More information about routing can be found in the :doc:`../incoming/routing`. - -Here, the second rule in the ``$routes`` object matches a GET request -to the URI path **/pages**, and it maps to the ``index()`` method of the ``Pages`` class. - -The third rule in the ``$routes`` object matches a GET request to a URI segment -using the placeholder ``(:segment)``, and passes the parameter to the -``view()`` method of the ``Pages`` class. - Running the App ***************