In the previous tutorial, we learned how to install/download Codeigniter 4 as well as how to run a downloaded project.
In this tutorial, we will describe the application directory structure of Codeigniter 4. Because the directory structure of the new Codeigniter 4 has changed.
Codeigniter 4 Application Folder / Directories Structure
The new Codeigniter 4 application directory structure looks like the below image:
When you have installed a fresh new Codeigniter 4, It has contained six important directories:
Note: Each of these directories has a very specific part to play.
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:
- /Config Stores the configuration files
- /Controllers Controllers determine the program flow
- /Database Stores the database migrations and seeds files
- /Filters Stores filter classes that can run before and after the controller
- /Helpers Helpers store collections of standalone functions
- /Language Multiple language support reads the language strings from here
- /Libraries Useful classes that don’t fit in another category
- /Models Models work with the database to represent the business entities.
- /ThirdParty ThirdParty libraries that can be used in application
- /Views Views make up the HTML that is displayed to the client.
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.
This folder is meant to be the “webroot” of your site, and your webserver would be configured to point to it.
This directory holds any directories that might need to be written 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 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.
If this directory is part of your project, it holds a local copy of the CodeIgniter4 User Guide.