Skip to content

Commit 74fea3f

Browse files
authored
Merge pull request #1265 from jim-parry/release/prep2
WIP Fix docs re PHP server
2 parents cfaaef8 + 2a53b62 commit 74fea3f

3 files changed

Lines changed: 57 additions & 6 deletions

File tree

user_guide_src/source/installation/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ By default, the application will run using the "production" environment. To
5454
take advantage of the debugging tools provided, you should set the environment
5555
to "develop".
5656

57+
.. caution:: Using PHP's built-in web server is likely to cause problems,
58+
as it does not process the `.htaccess` file used to properly handle requests.
59+
5760
That's it!
5861

5962
If you're new to CodeIgniter, please read the :doc:`Getting

user_guide_src/source/installation/troubleshooting.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ do this open your *application/Config/App.php* file and change this::
2828
To this::
2929

3030
public $indexPage = 'index.php?';
31+
32+
The tutorial gives 404 errors everywhere :(
33+
-------------------------------------------
34+
35+
You can't follow the tutorial using PHP's built-in web server.
36+
It doesn't process the `.htaccess` file needed to route
37+
requests properly.
38+
39+
The solution: use Apache to server your site.

user_guide_src/source/tutorial/static_pages.rst

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
137170
Routing
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

145175
Using custom routing rules, you have the power to map any URI to any
146176
controller and method, and break free from the normal convention:
147177
``http://example.com/[controller-class]/[controller-method]/[arguments]``
148178

149179
Let'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

Comments
 (0)