Skip to content

Commit 5608ed4

Browse files
authored
Merge pull request #7028 from kenjis/fix-docs-upgrade_xxx
docs: update Upgrading from 3.x to 4.x Libraries
2 parents 9049168 + 7ec0faf commit 5608ed4

11 files changed

Lines changed: 27 additions & 17 deletions

File tree

user_guide_src/source/installation/upgrade_configuration.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ What has been changed
1515
=====================
1616

1717
- In CI4, the configurations are now stored in classes which extend ``CodeIgniter\Config\BaseConfig``.
18+
- The **application/config/config.php** in CI3 will be **app/Config/App.php**
19+
and some other files like **app/Config/Security.php** for the specific classes.
1820
- Within the configuration class, the config values are stored in public class properties.
1921
- The method to fetch config values has been changed.
2022

@@ -30,21 +32,21 @@ Upgrade Guide
3032
from the CI3 config into the new CI4 config class as public class properties.
3133
4. Now, you have to change the config fetching syntax everywhere you fetch config
3234
values. The CI3 syntax is something like ``$this->config->item('item_name');``.
33-
You have to change this into ``config('MyConfigFile')->item_name;``.
35+
You have to change this into ``config('MyConfig')->item_name;``.
3436

3537
Code Example
3638
============
3739

3840
CodeIgniter Version 3.x
3941
------------------------
4042

41-
Path: **application/config**:
43+
Path: **application/config/site.php**:
4244

4345
.. literalinclude:: upgrade_configuration/ci3sample/001.php
4446

4547
CodeIgniter Version 4.x
4648
-----------------------
4749

48-
Path: **app/Config**:
50+
Path: **app/Config/Site.php**:
4951

5052
.. literalinclude:: upgrade_configuration/001.php

user_guide_src/source/installation/upgrade_configuration/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use CodeIgniter\Config\BaseConfig;
66

7-
class CustomClass extends BaseConfig
7+
class Site extends BaseConfig
88
{
99
public $siteName = 'My Great Site';
1010
public $siteEmail = 'webmaster@example.com';

user_guide_src/source/installation/upgrade_database.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Documentations
1414
What has been changed
1515
=====================
1616
- The functionality in CI3 is basically the same as in CI4.
17-
- The method names have changed to camelCase and the query builder now needs to be initialized before you can run queries on it.
17+
- The method names have changed to camelCase and the :doc:`Query Builder <../database/query_builder>`
18+
now needs to be initialized before you can run queries on it.
1819

1920
Upgrade Guide
2021
=============

user_guide_src/source/installation/upgrade_file_upload/001.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ public function index()
1212
public function do_upload()
1313
{
1414
$this->validate([
15-
'userfile' => 'uploaded[userfile]|max_size[userfile,100]'
16-
. '|mime_in[userfile,image/png,image/jpg,image/gif]'
17-
. '|ext_in[userfile,png,jpg,gif]|max_dims[userfile,1024,768]',
15+
'userfile' => [
16+
'uploaded[userfile]',
17+
'max_size[userfile,100]',
18+
'mime_in[userfile,image/png,image/jpg,image/gif]',
19+
'ext_in[userfile,png,jpg,gif]',
20+
'max_dims[userfile,1024,768]',
21+
],
1822
]);
1923

2024
$file = $this->request->getFile('userfile');

user_guide_src/source/installation/upgrade_responses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ What has been changed
1717
Upgrade Guide
1818
=============
1919
1. The methods in the HTTP Responses class are named slightly different. The most important change in the naming is the switch from underscored method names to camelCase. The method ``set_content_type()`` from version 3 is now named ``setContentType()`` and so on.
20-
2. In the most cases you have to change ``$this->output`` to ``$this->response`` followed by the method. You can find all methods :doc:`here </outgoing/response>`.
20+
2. In the most cases you have to change ``$this->output`` to ``$this->response`` followed by the method. You can find all methods in :doc:`../outgoing/response`.
2121

2222
Code Example
2323
============

user_guide_src/source/installation/upgrade_security.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Documentations
1212
- :doc:`Security Documentation CodeIgniter 4.X </libraries/security>`
1313

1414
.. note::
15-
If you use the :doc:`form helper </helpers/form_helper>` and enable the CSRF filter globally, then ``form_open()`` will automatically insert a hidden CSRF field in your forms. So you do not have to upgrade this by yourself.
15+
If you use the :doc:`../helpers/form_helper` and enable the CSRF filter globally, then :php:func:`form_open()` will automatically insert a hidden CSRF field in your forms. So you do not have to upgrade this by yourself.
1616

1717
What has been changed
1818
=====================
19-
- The method to implement CSRF tokens to html forms has been changed.
19+
- The method to implement CSRF tokens to HTML forms has been changed.
2020

2121
Upgrade Guide
2222
=============

user_guide_src/source/installation/upgrade_security/001.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ class Filters extends BaseConfig
1414
'csrf',
1515
],
1616
];
17+
1718
// ...
1819
}

user_guide_src/source/installation/upgrade_sessions/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$session = session();
44

5-
$_SESSION['item'];
5+
$_SESSION['item']; // But we do not recommend to use superglobal directly.
66
$session->get('item');
77
$session->item;
88
session('item');

user_guide_src/source/installation/upgrade_validations.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Documentations of Library
1313

1414
What has been changed
1515
=====================
16-
- If you want to change validation error display, you have to set CI4 validation View templates.
16+
- If you want to change validation error display, you have to set CI4 :ref:`validation View templates <validation-customizing-error-display>`.
1717
- CI4 validation has no Callbacks nor Callable in CI3.
1818
- CI4 validation format rules do not permit empty string.
1919
- CI4 validation never changes your data.
@@ -29,7 +29,7 @@ Upgrade Guide
2929
- ``$this->load->helper(array('form', 'url'));`` to ``helper(['form', 'url']);``
3030
- remove the line ``$this->load->library('form_validation');``
3131
- ``if ($this->form_validation->run() == FALSE)`` to ``if (! $this->validate([]))``
32-
- ``$this->load->view('myform');`` to ``echo view('myform', ['validation' => $this->validator,]);``
32+
- ``$this->load->view('myform');`` to ``return view('myform', ['validation' => $this->validator,]);``
3333

3434
3. You have to change the validation rules. The new syntax is to set the rules as array in the controller:
3535

user_guide_src/source/installation/upgrade_validations/002.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public function index()
1313
if (! $this->validate([
1414
// Validation rules
1515
])) {
16-
echo view('myform', [
16+
return view('myform', [
1717
'validation' => $this->validator,
1818
]);
19-
} else {
20-
echo view('formsuccess');
2119
}
20+
21+
return view('formsuccess');
2222
}
2323
}

0 commit comments

Comments
 (0)