for server side code & web page
Please refer to the document in Codeigniter to have a detail understanding. Please basically it can be separated into two parts, application and system
It is the place where our main application will be put, all later codes commit should be into this file.
All the static fields like database location (in database.php) will be stored in this folder. You will need to modify the error_message.php in that folder later on.
The main place where all request is first processed, please take a look on user.php for example.
Our custom helper for doing our routine jobs will be put in here. It exists as a form of function but not class, you can think it is a Utility class that has static methods. Currently I do not see a need for adding any helper file in there, using the one provided by Codeigniter is good enough.
Our custom library for doing our routine jobs will be put in here. And it always exists as a form of class. Our two main libraries are REST_Controller.php (for handling RESTful request) and CORE_Controller.php (for handling session checking and validation as well as formulate the error and generate error message). Normally, you do not need to change the file in there, it will be covered by me.
The main place where all communications to database will happen in here. Please take user_model.php as the example.
The main place to return some views to user, since we don't need that (we only return JSON), you can skip this folder.
The core part of the framework, normally we will not modify any files in there. And it shares the same structure as the Application folder.
Please start with this line
``` // Please ignore the "?>" at the end. ```And end with this
```PHP /* End of file __filename__.php */ /* Location: ./application/__folder__/__filename__.php */ ```
For all RESTful controller,
please incl. this statement before defining the class
And define the class like this
For example, if you have a class called `trip`
// other functions go below...
}
<p>
And name the file as trip.php
<br>
Example can be found in user.php
</p>
<h4>In models</h4>
<p>
Define your class like this
</p>
```PHP
class Trip_model extends CI_Model {
// define the KEY and table name in here
// methods go below...
}
And name the file as trip_model.php
That's all you need to know when creating a new class.
Currently I have not yet finished writing all checking strategy on the CORE_Controller.php, but you still need to use that class, just initialize the class like the example above will be good enough.
- Please use core_controller as your responsing method
e.g. If you need to response failure message back to the app, please do this
Example: controllers/user.php -> register_post() method
If you need to response success message back to the app, please do this
After calling the above two methods, the server will STOP processing remaining codes.
More often enough, you need to send data back to client not only success message, you can do this
// Note that this method can be chained, i.e. $this->core_controller->add_return_data($key1, $value1)->add_return_data($key2, $value2)->add_return_data($key3, $value3);
// Please remember to call successfully_processed() in the end of the chain if no more processing is needed.
<p>
On the call of fail_response(), all added return data <b>will be dropped and will not be included</b> in the return message.
</p>