Merge pull request #1235 from jim-parry/doc/fixes

Doc/fixes
This commit is contained in:
Instructor, BCIT 2018-09-23 08:20:36 -07:00 committed by GitHub
commit 8ea6f226de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 171 additions and 99 deletions

View File

@ -12,18 +12,18 @@ how to work with the requests and responses within CodeIgniter.
What is HTTP?
=============
HTTP is simply a text-based language that allows two machines to talk to each other. When a browser
HTTP is simply a text-based convention that allows two machines to talk to each other. When a browser
requests a page, it asks the server if it can get the page. The server then prepares the page and sends
response back to the browser that asked for it. That's pretty much it. Obviously, there are some complexities
a response back to the browser that asked for it. That's pretty much it. Obviously, there are some complexities
that you can use, but the basics are really pretty simple.
HTTP is the term used to describe that language. It stands for HyperText Transfer Protocol. Your goal when
HTTP is the term used to describe that exchange convention. It stands for HyperText Transfer Protocol. Your goal when
you develop web applications is to always understand what the browser is requesting, and be able to
respond appropriately.
The Request
-----------
Whenever a client makes a request (a web browser, smartphone app, etc), it is sending a small text message
Whenever a client (a web browser, smartphone app, etc) makes a request, it sends a small text message
to the server and waits for a response.
The request would look something like this::
@ -67,7 +67,7 @@ Working with Requests and Responses
-----------------------------------
While PHP provides ways to interact with the request and response headers, CodeIgniter, like most frameworks,
abstract them so that you have a consistent, simple interface to them. The :doc:`IncomingRequest class </libraries/incomingrequest>`
abstracts them so that you have a consistent, simple interface to them. The :doc:`IncomingRequest class </libraries/incomingrequest>`
is an object-oriented representation of the HTTP request. It provides everything you need::
use CodeIgniter\HTTP\IncomingRequest;

View File

@ -73,11 +73,11 @@ then determine what to do with it. This often involves passing the data to a mod
the model that is then passed on to the view to be displayed. This also includes loading up other utility classes,
if needed, to handle specialized tasks that is outside of the purview of the model.
The other responsibility of the controller is to handles everything that pertains to HTTP requests - redirects,
The other responsibility of the controller is to handle everything that pertains to HTTP requests - redirects,
authentication, web safety, encoding, etc. In short, the controller is where you make sure that people are allowed to
be there, and they get the data they need in a format they can use.
Controllers are typically stored in **/application/Controllers**, though they can use a namespace to be grouped however
you need.
:doc:`Find out more about controllers </general/controllers>`
:doc:`Find out more about controllers </general/controllers>`

View File

@ -2,6 +2,10 @@
Services
########
.. contents::
:local:
:depth: 2
Introduction
============

View File

@ -74,14 +74,11 @@ production servers.
docs
----
This directory holds the CodeIgniter documentation. The ``user_guide`` subfolder contains a local copy of the
User Guide, and the ``api_docs`` subfolder contains a local copy of the CodeIgniter components API reference.
This directory holds a local copy of the CodeIgniter4
User Guide.
Modifying Directory Locations
-----------------------------
If you've relocated any of the main directories, you can let the application
know the new location within the main ``index.php`` file.
Starting around line 50, you will find three variables that hold the location to the **application**,
**system**, and **writable** directories. These paths are relative to **index.php**.
If you've relocated any of the main directories, you can change the configuration
settings inside ``application/Config/Paths``.

View File

@ -2,6 +2,10 @@
Database Configuration
######################
.. contents::
:local:
:depth: 2
CodeIgniter has a config file that lets you store your database
connection values (username, password, database name, etc.). The config
file is located at application/Config/Database.php. You can also set

View File

@ -6,8 +6,9 @@ CodeIgniter supports Entity classes as a first-class citizen in it's database la
them completely optional to use. They are commonly used as part of the Repository pattern, but can
be used directly with the :doc:`Model </database/model>` if that fits your needs better.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
Entity Usage
============

View File

@ -5,8 +5,9 @@ Database Forge Class
The Database Forge Class contains methods that help you manage your
database.
.. contents:: Table of Contents
:depth: 3
.. contents::
:local:
:depth: 2
****************************
Initializing the Forge Class

View File

@ -2,6 +2,10 @@
Database Metadata
#################
.. contents::
:local:
:depth: 2
**************
Table MetaData
**************

View File

@ -2,7 +2,9 @@
Queries
#######
.. contents:: Table of Contents
.. contents::
:local:
:depth: 2
************
Query Basics

View File

@ -17,7 +17,7 @@ system.
.. contents::
:local:
:depth: 1
:depth: 2
*************************
Loading the Query Builder

View File

@ -1,12 +1,14 @@
###################
Running via the CLI
###################
############################
Running via the Command Line
############################
As well as calling an applications :doc:`Controllers <./controllers>`
via the URL in a browser they can also be loaded via the command-line
interface (CLI).
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
What is the CLI?
================

View File

@ -8,7 +8,9 @@ need to have routes defined for, making them perfect for building tools that dev
their jobs simpler, whether by handling migrations or database seeding, checking cronjob status, or even
building out custom code generators for your company.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
****************
Running Commands

View File

@ -5,8 +5,10 @@ Global Functions and Constants
CodeIgniter uses provides a few functions and variables that are globally defined, and are available to you at any point.
These do not require loading any additional libraries or helpers.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
================
Global Functions

View File

@ -8,6 +8,10 @@ hold a class that contains its settings as public properties. Unlike in many oth
there is no single class that you need to use to access your settings. Instead, you simply
create an instance of the class and all your settings are there for you.
.. contents::
:local:
:depth: 2
Accessing Config Files
======================
@ -68,7 +72,7 @@ you will have settings that might change depending on the server it's running on
database settings, API credentials, and other settings that will vary between deploys.
You can store values in a **.env** file in the root directory, alongside the system and application directories.
It is simply a collection of name/value pairs separated by an equal sign, much like a .ini file::
It is simply a collection of name/value pairs separated by an equal sign, much like a ".ini" file::
S3_BUCKET="dotenv"
SECRET_KEY="super_secret_key"
@ -104,7 +108,7 @@ variable name within ``${...}``::
Namespaced Variables
====================
There will be times when you will have several variables of the same name. When this happens, the
There will be times when you will have several variables with the same name. When this happens, the
system has no way of knowing what the correct value should be. You can protect against this by
"namespacing" the variables.

View File

@ -4,7 +4,10 @@ Controllers
Controllers are the heart of your application, as they determine how HTTP requests should be handled.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
What is a Controller?
=====================
@ -240,23 +243,23 @@ Included Properties
Every controller you create should extend ``CodeIgniter\Controller`` class.
This class provides several features that are available to all of your controllers.
Request Object
--------------
**Request Object**
The application's main :doc:`Request Instance <../libraries/request>` is always available
as a class property, ``$this->request``.
Response Object
---------------
**Response Object**
The application's main :doc:`Response Instance <../libraries/response>` is always available
as a class property, ``$this->response``.
Logger Object
-------------
**Logger Object**
An instance of the :doc:`Logger <../general/logging>` class is available as a class property,
``$this->logger``.
forceHTTPS
----------
**forceHTTPS**
A convenience method for forcing a method to be accessed via HTTPS is available within all
controllers::

View File

@ -2,8 +2,9 @@
Debugging Your Application
**************************
.. contents:: Table of Contents
:depth: 3
.. contents::
:local:
:depth: 2
================
Replace var_dump

View File

@ -8,6 +8,10 @@ default action when an error or exception is thrown is to display a detailed err
is running under the ``production`` environment. In this case, a more generic message is displayed to
keep the best user experience for your users.
.. contents::
:local:
:depth: 2
Using Exceptions
================

View File

@ -2,6 +2,10 @@
Controller Filters
##################
.. contents::
:local:
:depth: 2
Controller Filters allow you to perform actions either before or after the controllers execute. Unlike :doc:`events </general/events>`,
you can very simply choose which URI's in your application have the filters applied to them. Incoming filters may
modify the Request, while after filters can act on and even modify the Response, allowing for a lot of flexibility
@ -173,8 +177,7 @@ a list of URI patterns that filter should apply to::
'bar' => ['before' => ['api/*', 'admin/*']]
];
================
Provided Filters
================
****************
To be determined.
Three filters are bundled with CodeIgniter4: Honeypot, Security, and Throttler.

View File

@ -9,6 +9,10 @@ you create form elements, **Text Helpers** perform various text formatting
routines, **Cookie Helpers** set and read cookies, **File Helpers** help you
deal with files, etc.
.. contents::
:local:
:depth: 2
Unlike most other systems in CodeIgniter, Helpers are not written in an
Object Oriented format. They are simple, procedural functions. Each
helper function performs one specific task, with no dependence on other

View File

@ -2,6 +2,10 @@
Logging Information
###################
.. contents::
:local:
:depth: 2
You can log information to the local log files by using the ``log_message()`` method. You must supply
the "level" of the error in the first parameter, indicating what type of message it is (debug, error, etc).
The second parameter is the message itself::

View File

@ -3,7 +3,7 @@ Managing your Applications
##########################
By default it is assumed that you only intend to use CodeIgniter to
manage one application, which you will build in your **application/**
manage one application, which you will build in your **application**
directory. It is possible, however, to have multiple sets of
applications that share a single CodeIgniter installation, or even to
rename or relocate your application directory.
@ -12,7 +12,7 @@ Renaming the Application Directory
==================================
If you would like to rename your application directory you may do so
as long as you open your main **index.php** file and set its name using
as long as you open **application/Config/Paths.php** file and set its name using
the ``$application_directory`` variable::
$application_directory = 'application';

View File

@ -7,7 +7,9 @@ centered around a specific subject, and can be thought of as mini-applications w
of the standard file types within the framework are supported, like controllers, models, views, config files, helpers,
language files, etc. Modules may contain as few, or as many, of these as you like.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
==========
Namespaces

View File

@ -2,7 +2,9 @@
URI Routing
###########
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
Typically there is a one-to-one relationship between a URL string and its corresponding
controller class/method. The segments in a URI normally follow this pattern::

View File

@ -2,6 +2,10 @@
View Parser
###########
.. contents::
:local:
:depth: 2
The View Parser can perform simple text substitution for
pseudo-variables contained within your view files.
It can parse simple variables or variable tag pairs.

View File

@ -2,6 +2,10 @@
View Renderer
#############
.. contents::
:local:
:depth: 2
The ``view()`` function is a convenience function that grabs an instance of the
``renderer`` service, sets the data, and renders the view. While this is often
exactly what you want, you may find times where you want to work with it more directly.
@ -96,7 +100,7 @@ Several options can be passed to the ``render()`` or ``renderString()`` methods:
- ``saveData`` - true if the view data parameters should be retained for subsequent calls
Class Reference
---------------
===============
.. php:class:: CodeIgniter\\View\\View

View File

@ -2,6 +2,10 @@
Views
#####
.. contents::
:local:
:depth: 2
A view is simply a web page, or a page fragment, like a header, footer, sidebar, etc. In fact,
views can flexibly be embedded within other views (within other views, etc.) if you need
this type of hierarchy.

View File

@ -2,12 +2,6 @@
Downloading CodeIgniter
#######################
- `CodeIgniter v4.0.0-dev (Upcoming version) <https://codeload.github.com/bcit-ci/CodeIgniter4/zip/develop>`_
******
GitHub
******
`Git <http://git-scm.com/about>`_ is a distributed version control system.
Public Git access is available at `GitHub <https://github.com/bcit-ci/CodeIgniter4>`_.
@ -15,4 +9,7 @@ Please note that while every effort is made to keep this code base
functional, we cannot guarantee the functionality of code taken from
the develop branch.
Stable versions are also available via `GitHub Releases <https://github.com/bcit-ci/CodeIgniter4/releases>`_.
Stable versions are available via `GitHub Releases <https://github.com/bcit-ci/CodeIgniter4/releases>`_.
You can also download a zip of the `development branch <https://codeload.github.com/bcit-ci/CodeIgniter4/zip/develop>`_,
i.e. the upcoming version.

View File

@ -7,8 +7,9 @@ single page application, or as a standalone product. CodeIgniter provides an API
used with any controller to make common response types simple, with no need to remember which HTTP status code
should be returned for which response types.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
*************
Example Usage
@ -97,9 +98,8 @@ So, if your request asks for JSON formatted data in an **Accept** header, the da
``respond*`` or ``fail*`` methods will be formatted by the **CodeIgniter\\API\\JSONFormatter** class. The resulting
JSON data will be sent back to the client.
===============
Class Reference
===============
***************
.. php:method:: respond($data[, $statusCode=200[, $message='']])

View File

@ -10,8 +10,9 @@ performance and memory statistics to help you decide which version is the best.
The Timer class is always active, being started from the moment the framework is invoked until right before
sending the output to the user, enabling a very accurate timing of the entire system execution.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
===============
Using the Timer

View File

@ -7,8 +7,9 @@ fast and dynamic caching. All but file-based caching require specific
server requirements, and a Fatal Exception will be thrown if server
requirements are not met.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
*************
Example Usage

View File

@ -10,7 +10,9 @@ CodeIgniter's CLI library makes creating interactive command-line scripts simple
* Showing progress bars during long tasks
* Wrapping long text lines to fit the window.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
Initializing the Class
======================

View File

@ -6,6 +6,10 @@ The ``CURLRequest`` class is a lightweight HTTP client based on CURL that allows
web sites and servers. It can be used to get the contents of a Google search, retrieve a web page or image,
or communicate with an API, among many other things.
.. contents::
:local:
:depth: 2
This class is modelled after the `Guzzle HTTP Client <http://docs.guzzlephp.org/en/latest/>`_ library since
it is one of the more widely used libraries. Where possible, the syntax has been kept the same so that if
your application needs something a little more powerful than what this library provides, you will have

View File

@ -17,7 +17,8 @@ CodeIgniter's robust Email Class supports the following features:
- Email Debugging tools
.. contents::
:local:
:local:
:depth: 2
.. raw:: html

View File

@ -6,8 +6,9 @@ CodeIgniter provides a File class that wraps the `SplFileInfo <http://php.net/ma
and provides some additional convenience methods. This class is the base class for :doc:`uploaded files </libraries/uploaded_files>`
and :doc:`images </libraries/images>`.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
Getting a File instance
=======================

View File

@ -7,7 +7,9 @@ If it's enabled in ``Application\Config\Filters.php`` file. This is done by atta
and this form field is hidden from human but accessible to Bot. When data is entered into the field it's
assumed the request is coming from a Bot, then an execption is thrown.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
Enabling Honeypot
=====================

View File

@ -15,6 +15,7 @@ The following image libraries are supported: GD/GD2, and ImageMagick.
.. contents::
:local:
:depth: 2
**********************
Initializing the Class

View File

@ -6,7 +6,9 @@ The IncomingRequest class provides an object-oriented representation of an HTTP
It extends from, and has access to all the methods of the :doc:`Request </libraries/request>` and :doc:`Message </libraries/message>`
classes, in addition to the methods listed below.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
Accessing the Request
=====================

View File

@ -4,6 +4,7 @@ Localization
.. contents::
:local:
:depth: 2
********************
Working With Locales
@ -39,9 +40,9 @@ language codes like en-US for American English, or fr-FR, for French/France. A m
to this can be found on the `W3C's site <https://www.w3.org/International/articles/language-tags/>`_.
The system is smart enough to fallback to more generic language codes if an exact match
cannot be found. If the locale code was set to **en_US** and we only have language files setup for **en**
then those will be used since nothing exists for the more specific **en_US**. If, however, a language
directory existed at **application/Language/en_US** then that we be used first.
cannot be found. If the locale code was set to **en-US** and we only have language files setup for **en**
then those will be used since nothing exists for the more specific **en-US**. If, however, a language
directory existed at **application/Language/en-US** then that would be used first.
Locale Detection
================
@ -64,7 +65,7 @@ of locales that you have defined in ``$supportLocales``. If no match is found be
that you support, and the requested language, the first item in $supportedLocales will be used. In
the following example, the **en** locale would be used if no match is found::
public $supportedLocales = ['en', 'es', 'fr_FR'];
public $supportedLocales = ['en', 'es', 'fr-FR'];
In Routes
---------
@ -108,7 +109,7 @@ Language Localization
Creating Language Files
=======================
Language do not have any specific naming convention that are required. The file should be named logically to
Languages do not have any specific naming convention that are required. The file should be named logically to
describe the type of content it holds. For example, let's say you want to create a file containing error messages.
You might name it simply: **Errors.php**.
@ -234,12 +235,12 @@ third parameter to the ``lang()`` method.
::
// Displays "The time is now 23:21:28 GMT-5"
echo lang('Test.longTime', [time()], 'ru_RU');
echo lang('Test.longTime', [time()], 'ru-RU');
// Displays "£7.41"
echo lang('{price, number, currency}', ['price' => 7.41], 'en_GB');
echo lang('{price, number, currency}', ['price' => 7.41], 'en-GB');
// Displays "$7.41"
echo lang('{price, number, currency}', ['price' => 7.41], 'en_US');
echo lang('{price, number, currency}', ['price' => 7.41], 'en-US');
Nested Arrays
-------------

View File

@ -5,7 +5,9 @@ HTTP Responses
The Response class extends the :doc:`HTTP Message Class </libraries/message>` with methods only appropriate for
a server responding to the client that called it.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
Working with the Response
=========================

View File

@ -4,8 +4,9 @@ Security Class
The Security Class contains methods that help protect your site against Cross-Site Request Forgery attacks.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
*******************
Loading the Library

View File

@ -12,8 +12,9 @@ CodeIgniter comes with a few session storage drivers:
- redis
- memcached
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
.. raw:: html

View File

@ -4,6 +4,7 @@ Throttler
.. contents::
:local:
:depth: 2
The Throttler class provides a very simple way to limit an activity to be performed to a certain number of attempts
within a set period of time. This is most often used for performing rate limiting on API's, or restricting the number

View File

@ -9,8 +9,9 @@ is the **Time** class and lives in the **CodeIgniter\\I18n** namespace.
.. note:: Since the Time class extends DateTime, if there are features that you need that this class doesn't provide,
you can likely find them within the DateTime class itself.
.. contents:: Page Contents
.. contents::
:local:
:depth: 1
=============
Instantiating

View File

@ -2,7 +2,7 @@
Typography
##########
The Typography libary contains methods that help your format text
The Typography libary contains methods that help you format text
in semantically relevant ways.
*******************

View File

@ -8,8 +8,9 @@ array directly. This extends the :doc:`File class </libraries/files>` and thus g
.. note:: This is not the same as the File Uploading class in previous versions of CodeIgniter. This provides a raw
interface to the uploaded files with a few small features.
.. contents:: Page Contents
:local:
.. contents::
:local:
:depth: 2
===============
Accessing Files

View File

@ -6,7 +6,9 @@ CodeIngiter provides an object oriented solution for working with URI's in your
simple to ensure that the structure is always correct, no matter how complex the URI might be, as well as adding
relative URI to an existing one and have it resolved safely and correctly.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
======================
Creating URI instances

View File

@ -7,6 +7,7 @@ about the browser, mobile device, or robot visiting your site.
.. contents::
:local:
:depth: 2
**************************
Using the User Agent Class

View File

@ -5,7 +5,9 @@ Validation
CodeIgniter provides a comprehensive data validation class that
helps minimize the amount of code you'll write.
.. contents:: Page Contents
.. contents::
:local:
:depth: 2
********
Overview

View File

@ -44,14 +44,6 @@ The other option is to download the .phar file from the `phpUnit <https://phpuni
This is standalone file that should be placed within your project root.
phpunit.xml
===========
A basic configuration for phpUnit has already been defined in ``phpunit.xml.dist``. Any project-specific changes to
this file should be done in a separate file so that it doesn't get overwritten by any framework updates. Copying the file
to ``phpunit.xml`` will create a file that phpUnit will use instead of the original file.
************************
Testing Your Application
************************
@ -205,10 +197,7 @@ Removes all mocked classes from the Services class, bringing it back to its orig
Stream Filters
==============
Some stream filters have been provided as an alternate to these helper methods.
CITestStreamFilter
------------------
**CITestStreamFilter** provides an alternate to these helper methods.
You may need to test things that are difficult to test. Sometimes, capturing a stream, like PHP's own STDOUT, or STDERR,
might be helpful. The ``CITestStreamFilter`` helps you capture the output from the stream of your choice.