Skip to content

Commit 14dfcfb

Browse files
committed
docs: add about Factories
1 parent ea1b628 commit 14dfcfb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

user_guide_src/source/installation/upgrade_4xx.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,17 @@ Class Loading
100100
namespaces; with Composer autoloading support.
101101
- You can configure the class loading to support whatever application structure
102102
you are most comfortable with, including the "HMVC" style.
103+
- Ci4 provides :doc:`../concepts/factories` that can load a class and share the
104+
instance like ``$this->load`` in CI3.
103105

104106
Libraries
105107
=========
106108

107109
- Your app classes can still go inside **app/Libraries**, but they don't have to.
108110
- Instead of CI3's ``$this->load->library('x');`` you can now use
109-
``$this->x = new X();``, following namespaced conventions for your component.
111+
``$this->x = new \App\Libraries\X();``, following namespaced conventions for
112+
your component. Alternatively, you can use :doc:`../concepts/factories`:
113+
``$this->x = \CodeIgniter\Config\Factories::libraries('X');``.
110114

111115
Helpers
112116
=======
@@ -160,8 +164,10 @@ Upgrading Libraries
160164
*******************
161165

162166
- Your app classes can still go inside **app/Libraries**, but they don't have to.
163-
- Instead of CI3's ``$this->load->library('x');`` you can now use ``$this->x = new X();``,
164-
following namespaced conventions for your component.
167+
- Instead of CI3's ``$this->load->library('x');`` you can now use
168+
``$this->x = new \App\Libraries\X();``, following namespaced conventions for
169+
your component. Alternatively, you can use :doc:`../concepts/factories`:
170+
``$this->x = \CodeIgniter\Config\Factories::libraries('X');``.
165171
- Some libraries from CodeIgniter 3 no longer exists in Version 4. For all these
166172
libraries, you have to find a new way to implement your functions. These
167173
libraries are `Calendaring <http://codeigniter.com/userguide3/libraries/calendar.html>`_,

0 commit comments

Comments
 (0)