Skip to content

Commit ffbf4e6

Browse files
authored
Merge pull request #6027 from kenjis/fix-docs-concepts
docs: small improvements in concepts
2 parents 89dd01b + 95e5a6a commit ffbf4e6

7 files changed

Lines changed: 92 additions & 66 deletions

File tree

user_guide_src/source/concepts/autoloader.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ The autoloader is always active, being registered with ``spl_autoload_register()
2828
beginning of the framework's execution.
2929

3030
Configuration
31-
=============
31+
*************
3232

3333
Initial configuration is done in **app/Config/Autoload.php**. This file contains two primary
3434
arrays: one for the classmap, and one for PSR-4 compatible namespaces.
3535

3636
Namespaces
37-
==========
37+
**********
3838

3939
The recommended method for organizing your classes is to create one or more namespaces for your
4040
application's files. This is most important for any business-logic related classes, entity classes,
@@ -61,7 +61,7 @@ You will need to modify any existing files that are referencing the current name
6161
namespace has changed.
6262

6363
Classmap
64-
========
64+
********
6565

6666
The classmap is used extensively by CodeIgniter to eke the last ounces of performance out of the system
6767
by not hitting the file-system with extra ``is_file()`` calls. You can use the classmap to link to
@@ -72,7 +72,7 @@ third-party libraries that are not namespaced:
7272
The key of each row is the name of the class that you want to locate. The value is the path to locate it at.
7373

7474
Composer Support
75-
================
75+
****************
7676

7777
Composer support is automatically initialized by default. By default, it looks for Composer's autoload file at
7878
``ROOTPATH . 'vendor/autoload.php'``. If you need to change the location of that file for any reason, you can modify

user_guide_src/source/concepts/factories.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Factories
77
:depth: 2
88

99
Introduction
10-
============
10+
************
1111

1212
What are Factories?
13-
-------------------
13+
===================
1414

1515
Like :doc:`./services`, **Factories** are an extension of autoloading that helps keep your code
1616
concise yet optimal, without having to pass around object instances between classes.
@@ -25,7 +25,7 @@ to work on or transmit common data. The framework itself uses Factories internal
2525
make sure the correct configuration is loaded when using the ``Config`` class.
2626

2727
Differences from Services
28-
-------------------------
28+
=========================
2929

3030
Factories require a concrete class name to instantiate and do not have code to create instances.
3131

@@ -37,7 +37,7 @@ that needs other services or class instances. When you get a service, Services r
3737
not a class name, so the returned instance can be changed without changing the client code.
3838

3939
Example
40-
-------
40+
=======
4141

4242
Take a look at **Models** as an example. You can access the Factory specific to Models
4343
by using the magic static method of the Factories class, ``Factories::models()``.
@@ -69,26 +69,26 @@ you get back the instance as before:
6969
.. literalinclude:: factories/003.php
7070

7171
Convenience Functions
72-
=====================
72+
*********************
7373

7474
Two shortcut functions for Factories have been provided. These functions are always available.
7575

7676
config()
77-
--------
77+
========
7878

7979
The first is ``config()`` which returns a new instance of a Config class. The only required parameter is the class name:
8080

8181
.. literalinclude:: factories/008.php
8282

8383
model()
84-
--------
84+
=======
8585

8686
The second function, ``model()`` returns a new instance of a Model class. The only required parameter is the class name:
8787

8888
.. literalinclude:: factories/009.php
8989

9090
Factory Parameters
91-
==================
91+
******************
9292

9393
``Factories`` takes as a second parameter an array of option values (described below).
9494
These directives will override the default options configured for each component.
@@ -106,7 +106,7 @@ class instance that uses the alternate database connection.
106106
.. _factories-options:
107107

108108
Factories Options
109-
==================
109+
*****************
110110

111111
The default behavior might not work for every component. For example, say your component
112112
name and its path do not align, or you need to limit instances to a certain type of class.
@@ -127,7 +127,7 @@ preferApp boolean Whether a class with the same basename in the App name
127127
========== ============== ============================================================ ===================================================
128128

129129
Factories Behavior
130-
==================
130+
******************
131131

132132
Options can be applied in one of three ways (listed in ascending priority):
133133

@@ -136,7 +136,7 @@ Options can be applied in one of three ways (listed in ascending priority):
136136
* Passing options directly at call time with a parameter.
137137

138138
Configurations
139-
--------------
139+
==============
140140

141141
To set default component options, create a new Config files at **app/Config/Factory.php**
142142
that supplies options as an array property that matches the name of the component.
@@ -154,7 +154,7 @@ This would prevent conflict of an third-party module which happened to have an
154154
unrelated ``Filters`` path in its namespace.
155155

156156
setOptions Method
157-
-----------------
157+
=================
158158

159159
The ``Factories`` class has a static method to allow runtime option configuration: simply
160160
supply the desired array of options using the ``setOptions()`` method and they will be
@@ -163,7 +163,7 @@ merged with the default values and stored for the next call:
163163
.. literalinclude:: factories/006.php
164164

165165
Parameter Options
166-
-----------------
166+
=================
167167

168168
``Factories``'s magic static call takes as a second parameter an array of option values.
169169
These directives will override the stored options configured for each component and can be
@@ -175,4 +175,4 @@ a component. By adding a second parameter to the magic static call, you can cont
175175
that single call will return a new or shared instance:
176176

177177
.. literalinclude:: factories/007.php
178-
:lines: 2-
178+
:lines: 2-

user_guide_src/source/concepts/http.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ concepts behind HTTP is a **must** for all developers that want to be successful
99
The first part of this chapter gives an overview. After the concepts are out of the way, we will discuss
1010
how to work with the requests and responses within CodeIgniter.
1111

12+
.. contents::
13+
:local:
14+
:depth: 2
15+
1216
What is HTTP?
13-
=============
17+
*************
1418

1519
HTTP is simply a text-based convention that allows two machines to talk to each other. When a browser
1620
requests a page, it asks the server if it can get the page. The server then prepares the page and sends
@@ -22,7 +26,8 @@ you develop web applications is to always understand what the browser is request
2226
respond appropriately.
2327

2428
The Request
25-
-----------
29+
===========
30+
2631
Whenever a client (a web browser, smartphone app, etc) makes a request, it sends a small text message
2732
to the server and waits for a response.
2833

@@ -42,7 +47,7 @@ client accepts, and much more. Wikipedia has an article that lists `all header f
4247
<https://en.wikipedia.org/wiki/List_of_HTTP_header_fields>`_ if you want to look it over.
4348

4449
The Response
45-
------------
50+
============
4651

4752
Once the server receives the request, your application will take that information and generate some output.
4853
The server will bundle your output as part of its response to the client. This is also represented as
@@ -64,7 +69,7 @@ wasn't found (404). Head over to IANA for a `full list of HTTP status codes
6469
<https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml>`_.
6570

6671
Working with Requests and Responses
67-
-----------------------------------
72+
***********************************
6873

6974
While PHP provides ways to interact with the request and response headers, CodeIgniter, like most frameworks,
7075
abstracts them so that you have a consistent, simple interface to them. The :doc:`IncomingRequest class </incoming/incomingrequest>`

user_guide_src/source/concepts/mvc.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22
Models, Views, and Controllers
33
##############################
44

5+
.. contents::
6+
:local:
7+
:depth: 2
8+
9+
************
10+
What is MVC?
11+
************
12+
513
Whenever you create an application, you have to find a way to organize the code to make it simple to locate
614
the proper files and make it simple to maintain. Like most of the web frameworks, CodeIgniter uses the Model,
715
View, Controller (MVC) pattern to organize the files. This keeps the data, the presentation, and flow through the
8-
application as separate parts. It should be noted that there are many views on the exact roles of each element,
16+
application as separate parts.
17+
18+
It should be noted that there are many views on the exact roles of each element,
919
but this document describes our take on it. If you think of it differently, you're free to modify how you use
1020
each piece as you need.
1121

@@ -18,7 +28,7 @@ the data storage.
1828

1929
At their most basic, controllers and models are simply classes that have a specific job. They are not the only class
2030
types that you can use, obviously, but they make up the core of how this framework is designed to be used. They even
21-
have designated directories in the **/app** directory for their storage, though you're free to store them
31+
have designated directories in the **app** directory for their storage, though you're free to store them
2232
wherever you desire, as long as they are properly namespaced. We will discuss that in more detail below.
2333

2434
Let's take a closer look at each of these three main components.

0 commit comments

Comments
 (0)