Skip to content

Commit

Permalink
Merge pull request #8886 from kenjis/docs-app-structure
Browse files Browse the repository at this point in the history
docs: improve concepts/structure.rst
  • Loading branch information
kenjis authored May 13, 2024
2 parents c7c4eb4 + ee5b087 commit 179d1bf
Showing 1 changed file with 42 additions and 27 deletions.
69 changes: 42 additions & 27 deletions user_guide_src/source/concepts/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Application Structure
#####################

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

.. contents::
:local:
Expand All @@ -12,15 +13,23 @@ can change to meet the needs of your application.
Default Directories
*******************

A fresh install has five directories: ``app/``, ``public/``,
``writable/``, ``tests/`` and ``vendor/`` or ``system/``.
A fresh install has five directories:

- **app**
- **public**
- **writable**
- **tests**
- **vendor** or **system**

Each of these directories has a very specific part to play.

app
===

The ``app`` directory is where all of your application code lives. This comes with a default directory
structure that works well for many applications. The following folders make up the basic contents:
The **app** directory is where all of your application code lives. This comes
with a default directory structure that works well for many applications.

The following folders make up the basic contents:

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

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

All files in this directory live under the ``App`` namespace, though you are free to change that in
**app/Config/Constants.php**.
All files in this directory live under the ``App`` namespace, though you are free
to change that in **app/Config/Constants.php**.

system
======

.. note:: If you install CodeIgniter with Composer, the ``system`` is located in ``vendor/codeigniter4/framework/system``.
.. note:: If you install CodeIgniter with Composer, the **system** is located in
**vendor/codeigniter4/framework/system**.

This directory stores the files that make up the framework, itself. While you have a lot of flexibility in how you
use the application directory, the files in the system directory should never be modified. Instead, you should
extend the classes, or create new classes, to provide the desired functionality.
This directory stores the files that make up the framework, itself. While you
have a lot of flexibility in how you use the application directory, the files in
the system directory should never be modified. Instead, you should extend the
classes, or create new classes, to provide the desired functionality.

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

Expand All @@ -65,27 +75,32 @@ public

The **public** folder holds the browser-accessible portion of your web application,
preventing direct access to your source code.

It contains the main **.htaccess** file, **index.php**, and any application
assets that you add, like CSS, javascript, or
images.
assets that you add, like CSS, javascript, or images.

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

writable
========

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

You should add any other directories that your application will need to write to
here. This allows you to keep your other primary directories non-writable as an
added security measure.

tests
=====

This directory is set up to hold your test files. The ``_support`` directory holds various mock classes and other
utilities that you can use while writing your tests. This directory does not need to be transferred to your
production servers.
This directory is set up to hold your test files. The **_support** directory
holds various mock classes and other utilities that you can use while writing
your tests.

This directory does not need to be transferred to your production servers.

Modifying Directory Locations
*****************************
Expand Down

0 comments on commit 179d1bf

Please sign in to comment.