Skip to content

Commit

Permalink
Merge pull request #2775 from jreklund/ug-tutorial
Browse files Browse the repository at this point in the history
Update on "Build Your First Application"
  • Loading branch information
MGatner authored Apr 1, 2020
2 parents b20d181 + 9d8308a commit 88377e0
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 173 deletions.
2 changes: 1 addition & 1 deletion user_guide_src/source/outgoing/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ into the `$option` array in the third parameter.

echo view('blogview', $data, ['saveData' => true]);

Additionally, if you would like the default functionality of the view method to be that it does save the data
Additionally, if you would like the default functionality of the view function to be that it does save the data
between calls, you can set ``$saveData`` to **true** in **app/Config/Views.php**.

Creating Loops
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/tutorial/conclusion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ design patterns, which you can expand upon.
Now that you've completed this tutorial, we recommend you check out the
rest of the documentation. CodeIgniter is often praised because of its
comprehensive documentation. Use this to your advantage and read the
"Introduction" and "General Topics" sections thoroughly. You should read
"Overview" and "General Topics" sections thoroughly. You should read
the class and helper references when needed.

Every intermediate PHP programmer should be able to get the hang of
Expand Down
36 changes: 18 additions & 18 deletions user_guide_src/source/tutorial/create_news_items.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ the slug from our title in the model. Create a new view at

</form>

There is only one thing here that probably look unfamiliar to you: the
There is only one thing here that probably look unfamiliar to you: the
``\Config\Services::validation()->listErrors()`` function. It is used to report
errors related to form validation.

Expand All @@ -46,7 +46,6 @@ validation <../libraries/validation>` library to do this.

public function create()
{
helper('form');
$model = new NewsModel();

if (! $this->validate([
Expand All @@ -57,7 +56,6 @@ validation <../libraries/validation>` library to do this.
echo view('templates/header', ['title' => 'Create a news item']);
echo view('news/create');
echo view('templates/footer');

}
else
{
Expand All @@ -66,14 +64,14 @@ validation <../libraries/validation>` library to do this.
'slug' => url_title($this->request->getVar('title')),
'body' => $this->request->getVar('body'),
]);

echo view('news/success');
}
}

The code above adds a lot of functionality. The first few lines load the
form helper and the NewsModel. After that, the Controller-provided helper
function is used to validate the $_POST fields. In this case, the title and
text fields are required.
The code above adds a lot of functionality. First we load the NewsModel.
After that, the Controller-provided helper function is used to validate
the $_POST fields. In this case, the title and text fields are required.

CodeIgniter has a powerful validation library as demonstrated
above. You can read :doc:`more about this library
Expand All @@ -83,18 +81,20 @@ Continuing down, you can see a condition that checks whether the form
validation ran successfully. If it did not, the form is displayed; if it
was submitted **and** passed all the rules, the model is called. This
takes care of passing the news item into the model.
This contains a new function, url\_title(). This function -
This contains a new function ``url_title()``. This function -
provided by the :doc:`URL helper <../helpers/url_helper>` - strips down
the string you pass it, replacing all spaces by dashes (-) and makes
sure everything is in lowercase characters. This leaves you with a nice
slug, perfect for creating URIs.

After this, a view is loaded to display a success message. Create a view at
**app/Views/news/success.php** and write a success message.
**app/Views/news/success.php** and write a success message.

This could be as simple as:::
This could be as simple as:

::

News item created successfully.
News item created successfully.

Model Updating
-------------------------------------------------------
Expand Down Expand Up @@ -134,8 +134,9 @@ Routing

Before you can start adding news items into your CodeIgniter application
you have to add an extra rule to **app/Config/Routes.php** file. Make sure your
file contains the following. This makes sure CodeIgniter sees 'create'
as a method instead of a news item's slug.
file contains the following. This makes sure CodeIgniter sees ``create``
as a method instead of a news item's slug. You can read more about different
routing types :doc:`here </incoming/routing>`.

::

Expand All @@ -158,15 +159,14 @@ Add some news and check out the different pages you made.
:height: 415px
:width: 45%

.. image:: ../images/tutorial9.png
:align: left


Congratulations
-------------------------------------------------------

You just completed your first CodeIgniter4 application!

The image to the left shows your project's **app** folder,
The image underneath shows your project's **app** folder,
with all of the files that you created in green.
The two modified configuration files (Database & Routes) are not shown.

.. image:: ../images/tutorial9.png
:align: left
8 changes: 4 additions & 4 deletions user_guide_src/source/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ From your command line type the following:

::

composer create-project codeigniter4/appstarter ci-blog -s rc
composer create-project codeigniter4/appstarter ci-news

This creates a new folder, ci-blog, which contains your application code, with
This creates a new folder, ci-news, which contains your application code, with
CodeIgniter installed in the vendor folder.

By default, CodeIgniter starts up in production mode. This is a safety feature
Expand Down Expand Up @@ -121,9 +121,9 @@ greeted by a screen looking something like this:
There are a couple of things to note here:

1. Hovering over the red header at the top reveals a ``search`` link that will open up
Google.com in a new tab and searching for the exception.
Google.com in a new tab and searching for the exception.
2. Clicking the ``arguments`` link on any line in the Backtrace will expand a list of
the arguments that were passed into that function call.
the arguments that were passed into that function call.

Everything else should be clear when you see it.

Expand Down
Loading

0 comments on commit 88377e0

Please sign in to comment.