From 20292311636837e120d205e470e41826820feb46 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 14:29:10 +0300 Subject: Change class filenames to Ucfirst --- user_guide_src/source/general/cli.rst | 2 +- user_guide_src/source/general/controllers.rst | 10 ++++--- .../source/general/creating_libraries.rst | 7 ++--- user_guide_src/source/general/libraries.rst | 2 +- user_guide_src/source/general/models.rst | 9 +++---- user_guide_src/source/general/styleguide.rst | 31 +++++++++++++++++++++- user_guide_src/source/general/views.rst | 2 +- 7 files changed, 47 insertions(+), 16 deletions(-) (limited to 'user_guide_src/source/general') 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:: '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 `. +:doc:`create your own 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/styleguide.rst b/user_guide_src/source/general/styleguide.rst index 144b362f5..1683b04cd 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:: Date: Mon, 22 Jul 2013 16:25:44 +0300 Subject: [ci skip] Fix style guide typos --- user_guide_src/source/general/styleguide.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst index 1683b04cd..5613eabec 100644 --- a/user_guide_src/source/general/styleguide.rst +++ b/user_guide_src/source/general/styleguide.rst @@ -97,8 +97,8 @@ Class files must be named in a Ucfirst-like manner, while any other file name **CORRECT**:: - SomeLibrary.php - Some_Library.php + Somelibrary.php + Some_library.php applicationconfig.php application_config.php -- cgit v1.2.3-24-g4f1b From 838c9a96f645aac24daa31285efa1051535c4219 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 14:05:13 +0300 Subject: Drop the unused parameter from log_message() / CI_Log::write_log() --- user_guide_src/source/general/common_functions.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 32e8a8be0..e085ef808 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -96,11 +96,10 @@ please see the :doc:`Error Handling ` 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, -- cgit v1.2.3-24-g4f1b From 0b58b3cad456efc5ecce89f622876c6b715439c2 Mon Sep 17 00:00:00 2001 From: Fatih Kalifa Date: Tue, 5 Nov 2013 15:36:40 +0700 Subject: Fix HTTP Verb Routing Rules Fix code style, removed (:any) rule in http verb to avoid confusion, and add proposed documentation and changelog --- user_guide_src/source/general/routing.rst | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 5520f59fe..6495f1ad4 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -142,6 +142,42 @@ routing rules to process the back-references. Example:: return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id; }; +Using HTTP Verb in Routes +========================= + +If you prefer you can use HTTP Verb (or method) to define your routing rules. +This is particularly useful when building RESTful application. You can use standard HTTP +Verb (GET, PUT, POST, DELETE) or custom HTTP Verb (e.g: PURGE). HTTP Verb rule is case +insensitive. All you need to do is add array index using HTTP Verb rule. Example:: + + $route['products']['put'] = 'product/insert'; + +In the above example, a PUT request to URI "products" would call the "product" controller +class and "insert" method + +:: + + $route['products/(:num)']['DELETE'] = 'product/delete/$1'; + +A DELETE request to URL with "products" as first segment and a number in the second will be +remapped to the "product" class and "delete" method passing in the match as a variable to +the method. + +:: + + $route['products/([a-z]+)/(\d+)']['get'] = 'product/$1/$2'; + +A GET request to a URI similar to products/shirts/123 would call the "product" controller +class and "shirt" method with number as method parameter + +Using HTTP Verb is optional, so if you want any HTTP Verb to be handled in one rule +You could just write your routing rule without HTTP Verb. Example:: + + $route['product'] = 'product'; + +This way, all incoming request using any HTTP method containing the word "product" +in the first segment will be remapped to "product" class + Reserved Routes =============== -- cgit v1.2.3-24-g4f1b From c761a206def7714d18623d46b05adc2bbeedce21 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Nov 2013 14:02:15 +0200 Subject: Polish changes from PR #2712 --- user_guide_src/source/general/routing.rst | 37 ++++++++++--------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 6495f1ad4..0b91d3fa9 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -142,41 +142,28 @@ routing rules to process the back-references. Example:: return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id; }; -Using HTTP Verb in Routes -========================= +Using HTTP verbs in routes +========================== -If you prefer you can use HTTP Verb (or method) to define your routing rules. -This is particularly useful when building RESTful application. You can use standard HTTP -Verb (GET, PUT, POST, DELETE) or custom HTTP Verb (e.g: PURGE). HTTP Verb rule is case -insensitive. All you need to do is add array index using HTTP Verb rule. Example:: +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" controller -class and "insert" method +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 segment and a number in the second will be -remapped to the "product" class and "delete" method passing in the match as a variable to -the method. - -:: - - $route['products/([a-z]+)/(\d+)']['get'] = 'product/$1/$2'; - -A GET request to a URI similar to products/shirts/123 would call the "product" controller -class and "shirt" method with number as method parameter - -Using HTTP Verb is optional, so if you want any HTTP Verb to be handled in one rule -You could just write your routing rule without HTTP Verb. Example:: - - $route['product'] = 'product'; +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. -This way, all incoming request using any HTTP method containing the word "product" -in the first segment will be remapped to "product" class +Using HTTP verbs is of course, optional. Reserved Routes =============== -- cgit v1.2.3-24-g4f1b From f964b16f3db95d655420dfae2012ee9fbb98a1a8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Nov 2013 17:04:55 +0200 Subject: Deprecate CI_Input::is_cli_request() and add common function is_cli() to replace it Calls to this function are often needed before the Input library is available --- user_guide_src/source/general/cli.rst | 2 +- user_guide_src/source/general/common_functions.rst | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst index 4145d5ccc..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 diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index e085ef808..2dfec9cc0 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -173,6 +173,19 @@ is_https() Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests). +is_cli() +======== + +.. php: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_usable() ================= -- cgit v1.2.3-24-g4f1b From 528591deb8f3a1b9663b43c66d75ba1a4059e8fe Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Thu, 9 Jan 2014 10:04:43 -0600 Subject: fix doc warnings --- user_guide_src/source/general/common_functions.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 2dfec9cc0..e9259795f 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -71,7 +71,7 @@ documentation for more information. show_error() ============ -.. php:function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') +.. php:function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') :noindex: :param mixed $message: Error message :param int $status_code: HTTP Response status code @@ -84,7 +84,7 @@ please see the :doc:`Error Handling ` documentation. show_404() ========== -.. php:function:: show_404($page = '', $log_error = TRUE) +.. php:function:: show_404($page = '', $log_error = TRUE) :noindex: :param string $page: URI string :param bool $log_error: Whether to log the error @@ -96,7 +96,7 @@ please see the :doc:`Error Handling ` documentation. log_message() ============= -.. php:function:: log_message($level, $message) +.. php:function:: log_message($level, $message) :noindex: :param string $level: Log level: 'error', 'debug' or 'info' :param string $message: Message to log -- cgit v1.2.3-24-g4f1b From 05be0879777021a73ca55548c6edd61d17012a4d Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Thu, 9 Jan 2014 10:10:30 -0600 Subject: d'oh - :noindex: in wrong place Signed-off-by: Connor Tumbleson --- user_guide_src/source/general/common_functions.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/general') diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index e9259795f..a1007cb4b 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -71,7 +71,7 @@ documentation for more information. show_error() ============ -.. php:function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') :noindex: +.. :noindex: php:function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') :param mixed $message: Error message :param int $status_code: HTTP Response status code @@ -84,7 +84,7 @@ please see the :doc:`Error Handling ` documentation. show_404() ========== -.. php:function:: show_404($page = '', $log_error = TRUE) :noindex: +.. :noindex: php:function:: show_404($page = '', $log_error = TRUE) :param string $page: URI string :param bool $log_error: Whether to log the error @@ -96,7 +96,7 @@ please see the :doc:`Error Handling ` documentation. log_message() ============= -.. php:function:: log_message($level, $message) :noindex: +.. :noindex: php:function:: log_message($level, $message) :param string $level: Log level: 'error', 'debug' or 'info' :param string $message: Message to log -- cgit v1.2.3-24-g4f1b From 155ee7231c0ef72dc362c7d6423b2e4600024d3c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 10 Jan 2014 15:50:54 +0200 Subject: Compress output before storing it to cache, if output compression is enabled Based on PR #964 --- user_guide_src/source/general/caching.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'user_guide_src/source/general') 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. -- cgit v1.2.3-24-g4f1b From 1c8245a22874051f5342824d5299d6ad55f4995c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 20 Jan 2014 10:28:20 +0200 Subject: Polish changes from PR #2830 --- user_guide_src/source/general/profiling.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/general') 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 -- cgit v1.2.3-24-g4f1b