Day two, I will tell you about developer flow using Code Igniter 4. This framework implement MVC seems like lumen / laravel. So you will found route, model, controller, and view. If you never using MVC framework. Let me tell you the developer flow, let create one API with code igniter.
A. Setting Database
Open your project folder than go to app/config/database.php. Make sure that you have create new database before you registering on CI. Change configuration as your setting.
B. Create New Route
After you setting your database configuration, Now let’s start with adding new route. open app/config/Routes.php. than add line like this.
- $routes = we create new routes
- get() = method of this api
- /index = link to call this api
- Index: = name of controller execute
- :api = name of function in controller
C. Create New Controller
After that let’s create new controller, create new file give it name Index.php on folder controller. then fill code like below.
On that controller we can see that, Name of this controller is Index.php. in this controller there are function api(). This configuration seems like what we declare on route. That’s the point.
Controller is file where you code backend process like get data from database, update data, delete data, calculate some data, joining table or anything about logical form you code here on controller.
D. Test Your API
Open postman, then call your API. Match your method. See picture below.
If you get result like that, you got it. Still easy right ? Of Course, Next we will make harder.
The simple flow to develop using CI framework or other MVC framework just simple like flow diagram below
Route for routing, declare link to access, name of controller, and function name. After that we create controlle to create logical back-end process. After that test in your postman. If you don’t have postman download in this link
If you have some question just mention on comment section.