1+ #########################
12RESTful Resource Handling
2- #######################################################
3+ #########################
34
45.. contents ::
56 :local:
@@ -22,8 +23,9 @@ most "RESTful" your application would be considered.
2223CodeIgniter makes it easy to create RESTful APIs for your resources,
2324with its resource routes and `ResourceController `.
2425
26+ ***************
2527Resource Routes
26- ============================================================
28+ ***************
2729
2830You can quickly create a handful of RESTful routes for a single resource with the ``resource() `` method. This
2931creates the five most common routes needed for full CRUD of a resource: create a new resource, update an existing one,
@@ -43,23 +45,23 @@ generate update and delete methods that work with HTML forms:
4345.. literalinclude :: restful/002.php
4446
4547Change the Controller Used
46- --------------------------
48+ ==========================
4749
4850You can specify the controller that should be used by passing in the ``controller `` option with the name of
4951the controller that should be used:
5052
5153.. literalinclude :: restful/003.php
5254
5355Change the Placeholder Used
54- ---------------------------
56+ ===========================
5557
5658By default, the ``(:segment) `` placeholder is used when a resource ID is needed. You can change this by passing
5759in the ``placeholder `` option with the new string to use:
5860
5961.. literalinclude :: restful/004.php
6062
6163Limit the Routes Made
62- ---------------------
64+ =====================
6365
6466You can restrict the routes generated with the ``only `` option. This should be **an array ** or **comma separated list ** of method names that should
6567be created. Only routes that match one of these methods will be created. The rest will be ignored:
@@ -72,8 +74,9 @@ Otherwise you can remove unused routes with the ``except`` option. This should a
7274
7375Valid methods are: ``index ``, ``show ``, ``create ``, ``update ``, ``new ``, ``edit `` and ``delete ``.
7476
77+ ******************
7578ResourceController
76- ============================================================
79+ ******************
7780
7881The ``ResourceController `` provides a convenient starting point for your RESTful API,
7982with methods that correspond to the resource routes above.
@@ -87,8 +90,9 @@ The routing for this would be:
8790
8891.. literalinclude :: restful/008.php
8992
93+ ****************
9094Presenter Routes
91- ============================================================
95+ ****************
9296
9397You can quickly create a presentation controller which aligns
9498with a resource controller, using the ``presenter() `` method. This
@@ -111,23 +115,23 @@ controller. You need to distinguish them, for instance:
111115The second parameter accepts an array of options that can be used to modify the routes that are generated.
112116
113117Change the Controller Used
114- --------------------------
118+ ==========================
115119
116120You can specify the controller that should be used by passing in the ``controller `` option with the name of
117121the controller that should be used:
118122
119123.. literalinclude :: restful/011.php
120124
121125Change the Placeholder Used
122- ---------------------------
126+ ===========================
123127
124128By default, the ``(:segment) `` placeholder is used when a resource ID is needed. You can change this by passing
125129in the ``placeholder `` option with the new string to use:
126130
127131.. literalinclude :: restful/012.php
128132
129133Limit the Routes Made
130- ---------------------
134+ =====================
131135
132136You can restrict the routes generated with the ``only `` option. This should be **an array ** or **comma separated list ** of method names that should
133137be created. Only routes that match one of these methods will be created. The rest will be ignored:
@@ -140,8 +144,9 @@ Otherwise you can remove unused routes with the ``except`` option. This should a
140144
141145Valid methods are: ``index ``, ``show ``, ``new ``, ``create ``, ``edit ``, ``update ``, ``remove `` and ``delete ``.
142146
147+ *****************
143148ResourcePresenter
144- ============================================================
149+ *****************
145150
146151The ``ResourcePresenter `` provides a convenient starting point for presenting views
147152of your resource, and processing data from forms in those views,
@@ -156,8 +161,9 @@ The routing for this would be:
156161
157162.. literalinclude :: restful/016.php
158163
164+ *******************************
159165Presenter/Controller Comparison
160- =============================================================
166+ *******************************
161167
162168This table presents a comparison of the default routes created by `resource() `
163169and `presenter() ` with their corresponding Controller functions.
0 commit comments