summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/general
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/general')
-rw-r--r--user_guide_src/source/general/cli.rst2
-rw-r--r--user_guide_src/source/general/common_functions.rst7
-rw-r--r--user_guide_src/source/general/controllers.rst10
-rw-r--r--user_guide_src/source/general/creating_libraries.rst7
-rw-r--r--user_guide_src/source/general/libraries.rst2
-rw-r--r--user_guide_src/source/general/models.rst9
-rw-r--r--user_guide_src/source/general/routing.rst14
-rw-r--r--user_guide_src/source/general/styleguide.rst31
-rw-r--r--user_guide_src/source/general/urls.rst18
-rw-r--r--user_guide_src/source/general/views.rst2
10 files changed, 61 insertions, 41 deletions
diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst
index 998d2a907..4145d5ccc 100644
--- a/user_guide_src/source/general/cli.rst
+++ b/user_guide_src/source/general/cli.rst
@@ -33,7 +33,7 @@ Let's try it: Hello World!
==========================
Let's create a simple controller so you can see it in action. Using your
-text editor, create a file called tools.php, and put the following code
+text editor, create a file called Tools.php, and put the following code
in it::
<?php
diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst
index a133fdc6d..e085ef808 100644
--- a/user_guide_src/source/general/common_functions.rst
+++ b/user_guide_src/source/general/common_functions.rst
@@ -68,10 +68,6 @@ accessing configuration information, however ``config_item()`` can be used
to retrieve single keys. See :doc:`Config Library <../libraries/config>`
documentation for more information.
-.. important:: This function only returns values set in your configuration
- files. It does not take into account config values that are
- dynamically set at runtime.
-
show_error()
============
@@ -100,11 +96,10 @@ please see the :doc:`Error Handling <errors>` documentation.
log_message()
=============
-.. php:function:: log_message($level, $message, $php_error = FALSE)
+.. php:function:: log_message($level, $message)
:param string $level: Log level: 'error', 'debug' or 'info'
:param string $message: Message to log
- :param bool $php_error: Whether we're logging a native PHP error message
:returns: void
This function is an alias for ``CI_Log::write_log()``. For more info,
diff --git a/user_guide_src/source/general/controllers.rst b/user_guide_src/source/general/controllers.rst
index 04f23276d..d8ef824fb 100644
--- a/user_guide_src/source/general/controllers.rst
+++ b/user_guide_src/source/general/controllers.rst
@@ -18,7 +18,7 @@ Consider this URI::
example.com/index.php/blog/
In the above example, CodeIgniter would attempt to find a controller
-named blog.php and load it.
+named Blog.php and load it.
**When a controller's name matches the first segment of a URI, it will
be loaded.**
@@ -27,7 +27,7 @@ Let's try it: Hello World!
==========================
Let's create a simple controller so you can see it in action. Using your
-text editor, create a file called blog.php, and put the following code
+text editor, create a file called Blog.php, and put the following code
in it::
<?php
@@ -41,6 +41,8 @@ in it::
Then save the file to your *application/controllers/* directory.
+.. important:: The file must be called 'Blog.php', with a capital 'B'.
+
Now visit the your site using a URL similar to this::
example.com/index.php/blog/
@@ -136,7 +138,7 @@ present, as will be the case when only your site root URL is requested.
To specify a default controller, open your **application/config/routes.php**
file and set this variable::
- $route['default_controller'] = 'blog';
+ $route['default_controller'] = 'Blog';
Where Blog is the name of the controller class you want used. If you now
load your main index.php file without specifying any URI segments you'll
@@ -272,7 +274,7 @@ and place your controller classes within them.
specify the folder. For example, let's say you have a controller located
here::
- application/controllers/products/shoes.php
+ application/controllers/products/Shoes.php
To call the above controller your URI will look something like this::
diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst
index 4fc8ed72f..4beb600da 100644
--- a/user_guide_src/source/general/creating_libraries.rst
+++ b/user_guide_src/source/general/creating_libraries.rst
@@ -42,8 +42,7 @@ Naming Conventions
The Class File
==============
-Classes should have this basic prototype (Note: We are using the name
-Someclass purely as an example)::
+Classes should have this basic prototype::
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
@@ -56,6 +55,8 @@ Someclass purely as an example)::
/* End of file Someclass.php */
+.. note:: We are using the name Someclass purely as an example.
+
Using Your Class
================
@@ -81,7 +82,7 @@ constructor::
$params = array('type' => 'large', 'color' => 'red');
- $this->load->library('Someclass', $params);
+ $this->load->library('someclass', $params);
If you use this feature you must set up your class constructor to expect
data::
diff --git a/user_guide_src/source/general/libraries.rst b/user_guide_src/source/general/libraries.rst
index 6e1c8b6dd..9bbda51bb 100644
--- a/user_guide_src/source/general/libraries.rst
+++ b/user_guide_src/source/general/libraries.rst
@@ -29,4 +29,4 @@ Creating Your Own Libraries
===========================
Please read the section of the user guide that discusses how to
-:doc:`create your own libraries <creating_libraries>`.
+:doc:`create your own libraries <creating_libraries>`. \ No newline at end of file
diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst
index a028a9569..c4fd12476 100644
--- a/user_guide_src/source/general/models.rst
+++ b/user_guide_src/source/general/models.rst
@@ -84,8 +84,7 @@ Where **Model_name** is the name of your class. Class names **must** have
the first letter capitalized with the rest of the name lowercase. Make
sure your class extends the base Model class.
-The file name will be a lower case version of your class name. For
-example, if your class is this::
+The file name must match the class name. For example, if this is your class::
class User_model extends CI_Model {
@@ -98,7 +97,7 @@ example, if your class is this::
Your file will be this::
- application/models/user_model.php
+ application/models/User_model.php
Loading a Model
===============
@@ -111,7 +110,7 @@ the following method::
If your model is located in a sub-directory, include the relative path
from your models directory. For example, if you have a model located at
-*application/models/blog/queries.php* you'll load it using::
+*application/models/blog/Queries.php* you'll load it using::
$this->load->model('blog/queries');
@@ -181,4 +180,4 @@ database. The following options for connecting are available to you:
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
- $this->load->model('Model_name', '', $config); \ No newline at end of file
+ $this->load->model('model_name', '', $config); \ No newline at end of file
diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
index 123257fc8..5520f59fe 100644
--- a/user_guide_src/source/general/routing.rst
+++ b/user_guide_src/source/general/routing.rst
@@ -145,7 +145,7 @@ routing rules to process the back-references. Example::
Reserved Routes
===============
-There are two reserved routes::
+There are three reserved routes::
$route['default_controller'] = 'welcome';
@@ -165,5 +165,17 @@ error page. It won't affect to the ``show_404()`` function, which will
continue loading the default *error_404.php* file at
*application/views/errors/error_404.php*.
+
+::
+
+ $route['translate_uri_dashes'] = FALSE;
+
+As evident by the boolean value, this is not exactly a route. This
+option enables you to automatically replace dashes ('-') with
+underscores in the controller and method URI segments, thus saving you
+additional route entries if you need to do that.
+This is required, because the dash isn't a valid class or method name
+character and would cause a fatal error if you try to use it.
+
.. important:: The reserved routes must come before any wildcard or
regular expression routes. \ No newline at end of file
diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst
index 144b362f5..5613eabec 100644
--- a/user_guide_src/source/general/styleguide.rst
+++ b/user_guide_src/source/general/styleguide.rst
@@ -71,13 +71,42 @@ identify a file as being complete and not truncated.
echo "Here's my code!";
- /* End of file myfile.php */
+ /* End of file Myfile.php */
/* Location: ./system/modules/mymodule/myfile.php */
.. note:: There should be no empty line or newline character(s) following
the closing comments. If you happen to see one when
submitting a pull request, please check your IDE settings and fix it.
+File Naming
+===========
+
+Class files must be named in a Ucfirst-like manner, while any other file name
+(configurations, views, generic scripts, etc.) should be in all lowercase.
+
+**INCORRECT**::
+
+ somelibrary.php
+ someLibrary.php
+ SOMELIBRARY.php
+ Some_Library.php
+
+ Application_config.php
+ Application_Config.php
+ applicationConfig.php
+
+**CORRECT**::
+
+ Somelibrary.php
+ Some_library.php
+
+ applicationconfig.php
+ application_config.php
+
+Furthermore, class file names should match the name of the class itself.
+For example, if you have a class named `Myclass`, then its filename must
+be **Myclass.php**.
+
Class and Method Naming
=======================
diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst
index d678e4a0a..ca44e2f4c 100644
--- a/user_guide_src/source/general/urls.rst
+++ b/user_guide_src/source/general/urls.rst
@@ -32,24 +32,6 @@ The :doc:`URI Library <../libraries/uri>` and the :doc:`URL Helper
with your URI data. In addition, your URLs can be remapped using the
:doc:`URI Routing <routing>` feature for more flexibility.
-Friendly URLs
-=============
-
-As you might guess, since there's a straight relationship between
-URI segments and the controller/method pair that's being called,
-those two determining segments must represent a valid class and
-method name.
-You may however also use dashes in the class/method-representing
-segments, and they will automatically be translated to underscores
-in order to be valid routed segments.
-
-For example::
-
- example.com/my-settings/change-password/
-
-The above example will route to the ``My_settings`` controller and
-its method ``change_password()``.
-
Removing the index.php file
===========================
diff --git a/user_guide_src/source/general/views.rst b/user_guide_src/source/general/views.rst
index 4b1ab3c34..2fc0cb2ca 100644
--- a/user_guide_src/source/general/views.rst
+++ b/user_guide_src/source/general/views.rst
@@ -45,7 +45,7 @@ Where name is the name of your view file.
.. note:: The .php file extension does not need to be specified
unless you use something other than .php.
-Now, open the controller file you made earlier called blog.php, and
+Now, open the controller file you made earlier called Blog.php, and
replace the echo statement with the view loading method::
<?php