Skip to content

Commit 0fe4dc7

Browse files
committed
[ci skip] Updated the tutorial intro page with more about getting started with it.
1 parent 8597be3 commit 0fe4dc7

4 files changed

Lines changed: 93 additions & 5 deletions

File tree

92.9 KB
Loading
38.7 KB
Loading

user_guide_src/source/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Getting Started
1818

1919
installation/index
2020

21+
****************************
22+
Build Your First Application
23+
****************************
24+
2125
.. toctree::
2226
:includehidden:
2327
:titlesonly:

user_guide_src/source/tutorial/index.rst

Lines changed: 89 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
########
2-
Tutorial
3-
########
1+
############################
2+
Build Your First Application
3+
############################
4+
5+
Overview
6+
********
47

58
This tutorial is intended to introduce you to the CodeIgniter4 framework
69
and the basic principles of MVC architecture. It will show you how a
@@ -26,7 +29,7 @@ small part of the functionality of the CodeIgniter framework. You'll go
2629
through the following pages:
2730

2831
- Introduction, this page, which gives you an overview of what to
29-
expect.
32+
expect and gets your default application downloaded and running.
3033
- :doc:`Static pages <static_pages>`, which will teach you the basics
3134
of controllers, views and routing.
3235
- :doc:`News section <news_section>`, where you'll start using models
@@ -45,4 +48,85 @@ Enjoy your exploration of the CodeIgniter framework.
4548
static_pages
4649
news_section
4750
create_news_items
48-
conclusion
51+
conclusion
52+
53+
Getting Up and Running
54+
**********************
55+
56+
You can download a release manually from the site, but for this tutorial we will
57+
use the recommended way and install the AppStarter package through Composer.
58+
From your command line type the following:
59+
60+
::
61+
62+
➜ composer create-project codeigniter4/appstarter ci-blog -s rc
63+
64+
This creates a new folder, ci-blog, which contains your application code, with
65+
CodeIgniter installed in the vendor folder.
66+
67+
By default, CodeIgniter starts up in production mode. This is a safety feature
68+
to keep your site a bit more secure in case settings are messed up once it is live.
69+
So first let's fix that. Copy or renmae the ``env`` file to ``.env``. Open it up.
70+
71+
This file contains server-specific settings. This means you never will need to
72+
commit any sensitive information to your version control system. It includes
73+
some of the most common ones you want to enter already, though they are all commented
74+
out. So uncomment the line with CI_ENVIRONMENT on it, and change ``production`` to
75+
``development``::
76+
77+
CI_ENVIRONMENT = development
78+
79+
With that out of the way it's time to view your application in a browser. You can
80+
serve it through any server of your choice, Apache, Nginx, etc, but CodeIgniter
81+
comes with a simple command that takes advantage of PHP's built-in server to get
82+
you up and running fast on your development machines. Type the following on the
83+
command line from the root of your project::
84+
85+
php spark serve
86+
87+
88+
The Welcome Page
89+
****************
90+
91+
Now point your browser to the correct URL you will be greeted by a welcome screen.
92+
Try it now by heading to the following URL:
93+
94+
::
95+
96+
http://localhost:8080
97+
98+
and you should be greeted by the following page:
99+
100+
.. image:: ../images/welcome.png
101+
102+
This means that your application works and you can start making changes to it.
103+
104+
Debugging
105+
*********
106+
107+
Now that you're in development mode, you'll see a toolbar on the bottom of your application.
108+
This toolbar contains a number of helpful items that you can reference during development.
109+
This will never show in production environments. Clicking any of the tabs along the bottom
110+
brings up additional information. Clicking the X on the right of the toolbar minimizes it
111+
to a small square with the CodeIgniter flame on it. If you click that the toolbar
112+
will show again.
113+
114+
In addition to this, CodeIgniter has some helpful error pages when you hit exceptions or
115+
other errors in your program. Open up ``app/Controllers/Home.php`` and change some line
116+
to generate an error (removing a semi-colon or brace should do the trick!). You will be
117+
greeted by a screen looking something like this:
118+
119+
.. image:: ../images/error.png
120+
121+
There are a couple of things to note here:
122+
123+
1. Hovering over the red header at the top reveals a ``search`` link that will open up
124+
Google.com in a new tab and searching for the exception.
125+
2. Clicking the ``arguments`` link on any line in the Backtrace will expand a list of
126+
the arguments that were passed into that function call.
127+
128+
Everything else should be clear when you see it.
129+
130+
131+
Now that we know how to get started and how to debug a little, let's get started building this
132+
small news application.

0 commit comments

Comments
 (0)