From 8d63cc67bc8671c31e530f1d795bd82c8d3e60b3 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 7 Apr 2011 11:52:41 +0100 Subject: Added CLI documentation. --- user_guide/general/cli.html | 150 ++++++++++++++++++++++++++++++++++++++++++++ user_guide/nav/nav.js | 1 + user_guide/toc.html | 2 + 3 files changed, 153 insertions(+) create mode 100644 user_guide/general/cli.html (limited to 'user_guide') diff --git a/user_guide/general/cli.html b/user_guide/general/cli.html new file mode 100644 index 000000000..affafadf7 --- /dev/null +++ b/user_guide/general/cli.html @@ -0,0 +1,150 @@ + + + + + +Running via the CLI : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

CodeIgniter User Guide Version 2.0.1

+
+ + + + + + + + + +
+ + +
+ + + +
+ +

Running via the CLI

+ +

+ As well as calling an applications Controllers via the URL in a browser they can also be loaded via the command-line interface (CLI). +

+ + + + + + +

What is the CLI?

+ +

The command-line interface is a text-based method of interacting with computers that looks like what most people remember as DOS.

+ + + +

Why run via the command-line?

+ +

+ There are many reasons for running CodeIgniter from the command-line, but they are not always obvious.

+ + + + +

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 in it:

+ + + +

Then save the file to your application/controllers/ folder.

+ +

Now normally you would visit the your site using a URL similar to this:

+ +example.com/index.php/tools/message/to + +

Instead, we are going to open Terminal in Mac/Lunix or go to Run > "cmd" in Windows and navigate to our CodeIgniter project.

+ +
+ $ cd /path/to/project;
+ $ php index.php tools message +
+ +

If you did it right, you should see Hello World!.

+ +
+ $ php index.php tools message "John Smith" +
+ +

Here we are passing it a argument in the same way that URL parameters work. "John Smith" is passed as a argument and output is: Hello John Smith!.

+ +

That's it!

+ +

That, in a nutshell, is all there is to know about controllers on the command line. Remember that this is just a normal controller, so routing and _remap works fine.

+ + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js index eaa5f6237..ce783fc27 100644 --- a/user_guide/nav/nav.js +++ b/user_guide/nav/nav.js @@ -58,6 +58,7 @@ function create_menu(basepath) '
  • Error Handling
  • ' + '
  • Caching
  • ' + '
  • Profiling Your Application
  • ' + + '
  • Running via the CLI
  • ' + '
  • Managing Applications
  • ' + '
  • Handling Multiple Environments
  • ' + '
  • Alternative PHP Syntax
  • ' + diff --git a/user_guide/toc.html b/user_guide/toc.html index 4e0b65212..3df1a4b3b 100644 --- a/user_guide/toc.html +++ b/user_guide/toc.html @@ -111,7 +111,9 @@ Table of Contents
  • Error Handling
  • Caching
  • Profiling Your Application
  • +
  • Running via the CLI
  • Managing Applications
  • +
  • Handling Multiple Environments
  • Alternative PHP Syntax
  • Security
  • PHP Style Guide
  • -- cgit v1.2.3-24-g4f1b