Skip to content

Commit 179d1bf

Browse files
authored
Merge pull request #8886 from kenjis/docs-app-structure
docs: improve concepts/structure.rst
2 parents c7c4eb4 + ee5b087 commit 179d1bf

1 file changed

Lines changed: 42 additions & 27 deletions

File tree

user_guide_src/source/concepts/structure.rst

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Application Structure
33
#####################
44

5-
To get the most out of CodeIgniter, you need to understand how the application is structured, by default, and what you
6-
can change to meet the needs of your application.
5+
To get the most out of CodeIgniter, you need to understand how the application
6+
is structured, by default, and what you can change to meet the needs of your
7+
application.
78

89
.. contents::
910
:local:
@@ -12,15 +13,23 @@ can change to meet the needs of your application.
1213
Default Directories
1314
*******************
1415

15-
A fresh install has five directories: ``app/``, ``public/``,
16-
``writable/``, ``tests/`` and ``vendor/`` or ``system/``.
16+
A fresh install has five directories:
17+
18+
- **app**
19+
- **public**
20+
- **writable**
21+
- **tests**
22+
- **vendor** or **system**
23+
1724
Each of these directories has a very specific part to play.
1825

1926
app
2027
===
2128

22-
The ``app`` directory is where all of your application code lives. This comes with a default directory
23-
structure that works well for many applications. The following folders make up the basic contents:
29+
The **app** directory is where all of your application code lives. This comes
30+
with a default directory structure that works well for many applications.
31+
32+
The following folders make up the basic contents:
2433

2534
.. code-block:: none
2635
@@ -36,25 +45,26 @@ structure that works well for many applications. The following folders make up t
3645
ThirdParty/ ThirdParty libraries that can be used in application
3746
Views/ Views make up the HTML that is displayed to the client
3847
39-
Because the ``app`` directory is already namespaced, you should feel free to modify the structure
40-
of this directory to suit your application's needs. For example, you might decide to start using the Repository
41-
pattern and Entity Models to work with your data. In this case, you could rename the ``Models`` directory to
42-
``Repositories``, and add a new ``Entities`` directory.
48+
Because the **app** directory is already namespaced, you should feel free to
49+
modify the structure of this directory to suit your application's needs.
4350

44-
.. note:: If you rename the ``Controllers`` directory, though, you will not be able to use the automatic method of
45-
routing to controllers, and will need to define all of your routes in the routes file.
51+
For example, you might decide to start using the Repository
52+
pattern and Entities to work with your data. In this case, you could rename the
53+
**Models** directory to **Repositories**, and add a new **Entities** directory.
4654

47-
All files in this directory live under the ``App`` namespace, though you are free to change that in
48-
**app/Config/Constants.php**.
55+
All files in this directory live under the ``App`` namespace, though you are free
56+
to change that in **app/Config/Constants.php**.
4957

5058
system
5159
======
5260

53-
.. note:: If you install CodeIgniter with Composer, the ``system`` is located in ``vendor/codeigniter4/framework/system``.
61+
.. note:: If you install CodeIgniter with Composer, the **system** is located in
62+
**vendor/codeigniter4/framework/system**.
5463

55-
This directory stores the files that make up the framework, itself. While you have a lot of flexibility in how you
56-
use the application directory, the files in the system directory should never be modified. Instead, you should
57-
extend the classes, or create new classes, to provide the desired functionality.
64+
This directory stores the files that make up the framework, itself. While you
65+
have a lot of flexibility in how you use the application directory, the files in
66+
the system directory should never be modified. Instead, you should extend the
67+
classes, or create new classes, to provide the desired functionality.
5868

5969
All files in this directory live under the ``CodeIgniter`` namespace.
6070

@@ -65,27 +75,32 @@ public
6575

6676
The **public** folder holds the browser-accessible portion of your web application,
6777
preventing direct access to your source code.
78+
6879
It contains the main **.htaccess** file, **index.php**, and any application
69-
assets that you add, like CSS, javascript, or
70-
images.
80+
assets that you add, like CSS, javascript, or images.
7181

7282
This folder is meant to be the "web root" of your site, and your web server
7383
would be configured to point to it.
7484

7585
writable
7686
========
7787

78-
This directory holds any directories that might need to be written to in the course of an application's life.
79-
This includes directories for storing cache files, logs, and any uploads a user might send. You should add any other
80-
directories that your application will need to write to here. This allows you to keep your other primary directories
81-
non-writable as an added security measure.
88+
This directory holds any directories that might need to be written to in the
89+
course of an application's life. This includes directories for storing cache
90+
files, logs, and any uploads a user might send.
91+
92+
You should add any other directories that your application will need to write to
93+
here. This allows you to keep your other primary directories non-writable as an
94+
added security measure.
8295

8396
tests
8497
=====
8598

86-
This directory is set up to hold your test files. The ``_support`` directory holds various mock classes and other
87-
utilities that you can use while writing your tests. This directory does not need to be transferred to your
88-
production servers.
99+
This directory is set up to hold your test files. The **_support** directory
100+
holds various mock classes and other utilities that you can use while writing
101+
your tests.
102+
103+
This directory does not need to be transferred to your production servers.
89104

90105
Modifying Directory Locations
91106
*****************************

0 commit comments

Comments
 (0)