@@ -134,21 +134,60 @@ view.
134134 match the case of the actual directory and file itself or the system will
135135 throw errors on case-sensitive platforms.
136136
137+ Running the App
138+ ---------------
139+
140+ Ready to test? You cannot run the app using PHP's built-in server,
141+ since it will not properly process the ``.htaccess `` rules that are provided in
142+ ``public ``, and which eliminate the need to specify "index.php/"
143+ as part of a URL. CodeIgniter has its own command that you can use though.
144+
145+ From the command line, at the root of your project:
146+
147+ php spark serve
148+
149+ will start a web server, accessible on port 8080. If you set the location field
150+ in your browser to ``localhost:8080 ``, you should see the CodeIgniter welcome page.
151+
152+ You can now try several URLs in the browser location field, to see what the `Pages `
153+ controller you made above produces...
154+
155+ - ``localhost:8080/pages `` will show the results from the `index ` method
156+ inside our `Pages ` controller, which is to display the CodeIgniter "welcome" page,
157+ because "index" is the default controller method
158+ - ``localhost:8080/pages/index `` will also show the CodeIgniter "welcome" page,
159+ because we explicitly asked for the "index" methid
160+ - ``localhost:8080/pages/view `` will show the "home" page that you made above,
161+ because it is the default "page" parameter to the `view() ` method.
162+ - ``localhost:8080/pages/view/home `` will also show the "home" page that you made above,
163+ because we explicitly asked for it
164+ - ``localhost:8080/pages/view/about `` will show the "about" page that you made above,
165+ because we explicitly asked for it
166+ - ``localhost:8080/pages/view/shop `` will show a "404 - File Not Found" error page,
167+ because there is no `application/Views/pages/shop.php `
168+
169+
137170Routing
138171-------
139172
140- The controller is now functioning! Point your browser to
141- ``[your-site-url]index.php/pages/view `` to see your page. When you visit
142- ``index.php/pages/view/about `` you'll see the about page, again including
143- the header and footer.
173+ The controller is now functioning!
144174
145175Using custom routing rules, you have the power to map any URI to any
146176controller and method, and break free from the normal convention:
147177``http://example.com/[controller-class]/[controller-method]/[arguments] ``
148178
149179Let's do that. Open the routing file located at
150- *application/Config/Routes.php * and add the following two lines.
151- Remove all other code that adds any element in the ``$route `` items.
180+ *application/Config/Routes.php * and look for the "Route Definitions"
181+ section of the configuration file.
182+
183+ The only uncommented line there to start with should be:::
184+
185+ $routes->add('/', 'Home::index');
186+
187+ This directive says that any incoming request without any content
188+ specified should be handled by the ``index `` method inside the ``Home `` controller.
189+
190+ Add the following two lines, in front of the route directive for '/'.
152191
153192::
154193
0 commit comments