You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/general/configuration.rst
+27-12Lines changed: 27 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,37 +18,52 @@ the application configuration files in the **app/Config** folder.
18
18
Working with Configuration Files
19
19
********************************
20
20
21
+
Getting a Config Object
22
+
=======================
23
+
21
24
You can access configuration files for your classes in several different ways.
22
25
23
-
- By using the ``new`` keyword to create an instance:
26
+
new keyword
27
+
-----------
24
28
25
-
.. literalinclude:: configuration/001.php
29
+
By using the ``new`` keyword to create an instance:
26
30
27
-
- By using the ``config()`` function:
31
+
.. literalinclude:: configuration/001.php
28
32
29
-
.. literalinclude:: configuration/002.php
33
+
config()
34
+
--------
30
35
31
-
All configuration object properties are public, so you access the settings like any other property:
36
+
By using the ``config()`` function:
32
37
33
-
.. literalinclude:: configuration/003.php
38
+
.. literalinclude:: configuration/002.php
34
39
35
-
If no namespace is provided, it will look for the file in all defined namespaces
36
-
as well as **app/Config/**.
40
+
If no namespace is provided, it will look for the file in the **app/Config**
41
+
folder first, and if not found, look for in the **Config** folder in all defined
42
+
namespaces.
37
43
38
44
All of the configuration files that ship with CodeIgniter are namespaced with
39
45
``Config``. Using this namespace in your application will provide the best
40
46
performance since it knows exactly where to find the files.
41
47
42
-
You can put configuration files in any folder you want by using a different namespace.
43
-
This allows you to put configuration files on the production server in a folder
44
-
that is not web-accessible while keeping it under **/app** for easy access
45
-
during development.
48
+
.. note:: ``config()`` finds the file in **app/Config/** when there is a class with the same shortname,
49
+
even if you specify a fully qualified class name like ``config(\Acme\Blog\Config\Blog::class)``.
50
+
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-loading-class` for more information.
51
+
52
+
Getting a Config Property
53
+
=========================
54
+
55
+
All configuration object properties are public, so you access the settings like any other property:
56
+
57
+
.. literalinclude:: configuration/003.php
46
58
47
59
Creating Configuration Files
48
60
****************************
49
61
50
62
When you need a new configuration, first you create a new file at your desired location.
51
63
The default file location (recommended for most cases) is **app/Config**.
64
+
65
+
You can put configuration files in any **Config** folder by using a different namespace.
66
+
52
67
The class should use the appropriate namespace, and it should extend
53
68
``CodeIgniter\Config\BaseConfig`` to ensure that it can receive environment-specific settings.
Copy file name to clipboardExpand all lines: user_guide_src/source/general/modules.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,7 +194,7 @@ Config files are automatically discovered whenever using the ``config()`` functi
194
194
195
195
.. note:: ``config()`` finds the file in **app/Config/** when there is a class with the same shortname,
196
196
even if you specify a fully qualified class name like ``config(\Acme\Blog\Config\Blog::class)``.
197
-
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`Factories Example <factories-example>` for more information.
197
+
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-loading-class` for more information.
198
198
199
199
Migrations
200
200
==========
@@ -250,7 +250,7 @@ Model files are automatically discovered whenever using the :php:func:`model()`
250
250
251
251
.. note:: ``model()`` finds the file in **app/Models/** when there is a class with the same shortname,
252
252
even if you specify a fully qualified class name like ``model(\Acme\Blog\Model\PostModel::class)``.
253
-
This is because ``model()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`Factories Example <factories-example>` for more information.
253
+
This is because ``model()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-loading-class` for more information.
0 commit comments