Application contains following directories at root
- /app
- /public
- /tests
- /vendor
- /writable
- /system
May or may not you will see /system or /tests folder at root.
The main folder from these folders where we do development i.e inside /app directory. Inside this app directory we should all development folders like Controllers, Models, Views, Config etc. We will see in details about each of these in few seconds.
Explanation of folder structure
/public – This folder contains index.php, .htaccess, public accessible folders and/or files. At intital stage application runs from this folder. In the application development if we need to keep assets like CSS, JS, Images etc then we need to store all them into /public folder. It’s name means public accessible folder.
/system – Core files/packages/libraries stores into this folder. Modifications into any of these files will crash your application or will not work as per its default behaviour. So it’s not recommended to do any changes there. CodeIgniter 4 provides many of core files which we use like Helpers, Libraries, Databases etc stores their core files inside this folder.
/vendor is same as /system.
/writable – Writable folder contains the temporary files like cache, logs etc. Modifying, deleting any files are not recommendable from this folder.
/app – Main application folder. It contains all the development modules like Config, Controllers, Views, Models, Helpers, etc. Inside this folder all code lives.
- Config – It contains application configurations – Like Routes, Database etc.
- Controllers – It works with Models & Views and develop an application working flow.
- Models – Database functional files.
- Views – End users representational layers, HTML basic files.
- Helpers – It contains the standalone functions which is basically created for doing some specific function.
- Libraries – Classes which contains some functions, methods which helps to develop an application.
- Language – Multiple language support
Along with all these folders, CodeIgniter 4 contains env file. It is environment file. In this file, we have many environment variables i.e configuration variables which we can set and use in application development.
While working, we need to change env to .env to use that.
Also CodeIgniter contains a spark CLI. This is the new module which has been added into version 4.x. We will see in upcoming tutorials.