diff options
Diffstat (limited to 'user_guide_src/source/general')
-rw-r--r-- | user_guide_src/source/general/caching.rst | 3 | ||||
-rw-r--r-- | user_guide_src/source/general/cli.rst | 4 | ||||
-rw-r--r-- | user_guide_src/source/general/common_functions.rst | 24 | ||||
-rw-r--r-- | user_guide_src/source/general/controllers.rst | 10 | ||||
-rw-r--r-- | user_guide_src/source/general/creating_libraries.rst | 7 | ||||
-rw-r--r-- | user_guide_src/source/general/libraries.rst | 2 | ||||
-rw-r--r-- | user_guide_src/source/general/models.rst | 9 | ||||
-rw-r--r-- | user_guide_src/source/general/profiling.rst | 6 | ||||
-rw-r--r-- | user_guide_src/source/general/routing.rst | 23 | ||||
-rw-r--r-- | user_guide_src/source/general/styleguide.rst | 31 | ||||
-rw-r--r-- | user_guide_src/source/general/views.rst | 2 |
11 files changed, 94 insertions, 27 deletions
diff --git a/user_guide_src/source/general/caching.rst b/user_guide_src/source/general/caching.rst index 48385d6c9..f499f6e93 100644 --- a/user_guide_src/source/general/caching.rst +++ b/user_guide_src/source/general/caching.rst @@ -45,6 +45,9 @@ you. Once the tag is in place, your pages will begin being cached. caching will only work if you are generating display for your controller with a :doc:`view <./views>`. +.. important:: If you change configuration options that might affect + your output, you have to manually delete your cache files. + .. note:: Before the cache files can be written you must set the file permissions on your *application/cache/* directory such that it is writable. diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst index 998d2a907..4f3b07d9e 100644 --- a/user_guide_src/source/general/cli.rst +++ b/user_guide_src/source/general/cli.rst @@ -23,7 +23,7 @@ but they are not always obvious. - Run your cron-jobs without needing to use *wget* or *curl* - Make your cron-jobs inaccessible from being loaded in the URL by - checking for ``$this->input->is_cli_request()`` + checking the return value of :func:`is_cli()`. - Make interactive "tasks" that can do things like set permissions, prune cache folders, run backups, etc. - Integrate with other applications in other languages. For example, a @@ -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 8c5166358..65ca026a1 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -13,7 +13,7 @@ loading any libraries or helpers. <div class="custom-index container"></div> -.. function:: is_php($version = '5.3.0') +.. function:: is_php([$version = '5.3.0']) :param string $version: Version number :returns: bool @@ -66,7 +66,7 @@ loading any libraries or helpers. to retrieve single keys. See :doc:`Config Library <../libraries/config>` documentation for more information. -.. :noindex: function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') +.. :noindex: function:: show_error($message, $status_code[, $heading = 'An Error Was Encountered']) :param mixed $message: Error message :param int $status_code: HTTP Response status code @@ -76,7 +76,7 @@ loading any libraries or helpers. This function calls ``CI_Exception::show_error()``. For more info, please see the :doc:`Error Handling <errors>` documentation. -.. :noindex: function:: show_404($page = '', $log_error = TRUE) +.. :noindex: function:: show_404([$page = ''[, $log_error = TRUE]]) :param string $page: URI string :param bool $log_error: Whether to log the error @@ -85,17 +85,16 @@ loading any libraries or helpers. This function calls ``CI_Exception::show_404()``. For more info, please see the :doc:`Error Handling <errors>` documentation. -.. :noindex: function:: log_message($level, $message, $php_error = FALSE) +.. :noindex: 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, please see the :doc:`Error Handling <errors>` documentation. -.. function:: set_status_header($code, $text = '') +.. function:: set_status_header($code[, $text = '']) :param int $code: HTTP Reponse status code :param string $text: A custom message to set with the status code @@ -109,7 +108,7 @@ loading any libraries or helpers. `See here <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>`_ for a full list of headers. -.. function:: remove_invisible_characters($str, $url_encoded = TRUE) +.. function:: remove_invisible_characters($str[, $url_encoded = TRUE]) :param string $str: Input string :param bool $url_encoded: Whether to remove URL-encoded characters as well @@ -147,8 +146,15 @@ loading any libraries or helpers. Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests). -function_usable() -================= +.. function:: is_cli() + + :returns: bool + + Returns TRUE if the application is run through the command line + and FALSE if not. + + .. note:: This function checks both if the ``PHP_SAPI`` value is 'cli' + or if the ``STDIN`` constant is defined. .. function:: function_usable($function_name) 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/profiling.rst b/user_guide_src/source/general/profiling.rst index 6dbd0be16..f29af8102 100644 --- a/user_guide_src/source/general/profiling.rst +++ b/user_guide_src/source/general/profiling.rst @@ -80,4 +80,8 @@ Key Description **session_data** Data stored in the current session TRUE **query_toggle_count** The number of queries after which the query block will default to 25 hidden. -======================= =================================================================== ========
\ No newline at end of file +======================= =================================================================== ======== + +.. note:: Disabling the **save_queries** setting in your database configuration + will also effectively disable profiling for database queries and render + the 'queries' setting above useless.
\ 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 5520f59fe..0b91d3fa9 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -142,6 +142,29 @@ routing rules to process the back-references. Example:: return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id; }; +Using HTTP verbs in routes +========================== + +It is possible to use HTTP verbs (request method) to define your routing rules. +This is particularly useful when building RESTful applications. You can use standard HTTP +verbs (GET, PUT, POST, DELETE, PATCH) or a custom one such (e.g. PURGE). HTTP verb rules +are case-insensitive. All you need to do is to add the verb as an array key to your route. +Example:: + + $route['products']['put'] = 'product/insert'; + +In the above example, a PUT request to URI "products" would call the ``Product::insert()`` +controller method. + +:: + + $route['products/(:num)']['DELETE'] = 'product/delete/$1'; + +A DELETE request to URL with "products" as first the segment and a number in the second will be +mapped to the ``Product::delete()`` method, passing the numeric value as the first parameter. + +Using HTTP verbs is of course, optional. + Reserved Routes =============== 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/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 |