Skip to content

Commit 1a1d618

Browse files
committed
docs: add section titles and note
1 parent c875d33 commit 1a1d618

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

user_guide_src/source/general/configuration.rst

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,24 @@ the application configuration files in the **app/Config** folder.
1818
Working with Configuration Files
1919
********************************
2020

21+
Getting a Config Object
22+
=======================
23+
2124
You can access configuration files for your classes in several different ways.
2225

23-
- By using the ``new`` keyword to create an instance:
26+
new keyword
27+
-----------
2428

25-
.. literalinclude:: configuration/001.php
29+
By using the ``new`` keyword to create an instance:
2630

27-
- By using the ``config()`` function:
31+
.. literalinclude:: configuration/001.php
2832

29-
.. literalinclude:: configuration/002.php
33+
config()
34+
--------
3035

31-
All configuration object properties are public, so you access the settings like any other property:
36+
By using the ``config()`` function:
3237

33-
.. literalinclude:: configuration/003.php
38+
.. literalinclude:: configuration/002.php
3439

3540
If no namespace is provided, it will look for the file in all defined namespaces
3641
as well as **app/Config/**.
@@ -39,10 +44,16 @@ All of the configuration files that ship with CodeIgniter are namespaced with
3944
``Config``. Using this namespace in your application will provide the best
4045
performance since it knows exactly where to find the files.
4146

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.
47+
.. note:: ``config()`` finds the file in **app/Config/** when there is a class with the same shortname,
48+
even if you specify a fully qualified class name like ``config(\Acme\Blog\Config\Blog::class)``.
49+
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-loading-class` for more information.
50+
51+
Getting a Config Property
52+
=========================
53+
54+
All configuration object properties are public, so you access the settings like any other property:
55+
56+
.. literalinclude:: configuration/003.php
4657

4758
Creating Configuration Files
4859
****************************
@@ -52,6 +63,11 @@ The default file location (recommended for most cases) is **app/Config**.
5263
The class should use the appropriate namespace, and it should extend
5364
``CodeIgniter\Config\BaseConfig`` to ensure that it can receive environment-specific settings.
5465

66+
You can put configuration files in any folder you want by using a different namespace.
67+
This allows you to put configuration files on the production server in a folder
68+
that is not web-accessible while keeping it under **/app** for easy access
69+
during development.
70+
5571
Define the class and fill it with public properties that represent your settings:
5672

5773
.. literalinclude:: configuration/004.php

0 commit comments

Comments
 (0)