[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/demos/quickstart/protected/pages/GettingStarted/ -> CommandLine.page (source)

   1  <com:TContent ID="body" >
   2  <h1 id="501">Command Line Tool</h1>
   3  <p>The optional <tt>prado-cli.php</tt> PHP script file in the <tt>framework</tt>
   4  directory provides command line tools to perform various tedious takes in Prado.
   5  The <tt>prado-cli.php</tt> can be used to create Prado project skeletons, create
   6  initial test fixtures, and access to an interactive PHP shell.
   7  </p>
   8  <h2 id="502">Requirements</h2>
   9  <p>
  10  To use the command line tool, you need to use your command prompt, command console
  11  or terminal. In addition, PHP must be able to execute PHP scripts from
  12  the command line.
  13  </p>
  14  
  15  <h2 id="503">Usage</h2>
  16  <p>
  17  If you type <tt>php path/to/framework/prado-cli.php</tt>, you should see
  18  the following information. Alternatively, if you are not on Windows, 
  19  you may try to change the <tt>prado-cli.php</tt> into an executable
  20  and execute it as a script</p>
  21  <com:TTextHighlighter Language="cli" CssClass="source">
  22  Command line tools for Prado 3.0.5.
  23  usage: php prado-cli.php action <parameter> [optional]
  24  example: php prado-cli.php -c mysite
  25  
  26  actions:
  27    -c <directory>
  28      Creates a Prado project skeleton for the given <directory>.
  29  
  30    -t <directory>
  31      Create test fixtures in the given <directory>.
  32  
  33    shell [directory]
  34      Runs a PHP interactive interpreter. Initializes the Prado
  35      application in the given [directory].
  36  </com:TTextHighlighter>
  37  
  38  <p>The <b>&lt;parameter&gt;</b> are required parameters and <b>[optional]</b>
  39  are optional parameters. </p>
  40  
  41  <h2 id="504">Creating a new Prado project skeleton</h2>
  42  
  43  <p>To create a Prado project skeleton, do the following:</p>
  44  <ol>
  45      <li>Change to the directory where you want to create the project skeleton.</li>
  46      <li>Type, <tt>php ../prado/framework/prado-cli.php -c helloworld</tt>, where
  47      <tt>helloworld</tt> is the directory name that you want to create the project skeleton files.</li>
  48      <li>Type, <tt>php ../prado/framework/prado-cli.php <b>-t</b> helloworld</tt> to create
  49      the test fixtures for the <tt>helloworld</tt> project.</li>
  50  </ol>
  51  
  52  <h2 id="505">Interactive Shell</h2>
  53  <p>
  54  The interactive shell allows you to evaluate PHP statements from the command line.
  55  The <tt>prado-cli.php</tt> script can be used to start the shell and load an existing
  56  Prado project. For example, let us load the blog demo project. Assume that your
  57  command line is in the <tt>prado</tt> distribution directory and you type.
  58  </p>
  59  <p>
  60  <com:TTextHighlighter Language="cli" CssClass="source">
  61  $: php framework/prado-cli.php shell demos/blog
  62  </com:TTextHighlighter>
  63  The output should be
  64  <com:TTextHighlighter Language="cli" CssClass="source">
  65  Command line tools for Prado 3.0.5.
  66  ** Loaded Prado application in directory "demos\blog\protected".
  67  PHP-Shell - Version 0.3.1
  68  (c) 2006, Jan Kneschke <jan@kneschke.de>
  69  
  70  >> use '?' to open the inline help
  71  
  72  >>
  73  </com:TTextHighlighter>
  74  Then we will get an instance of the Prado blog application, and from
  75  that instance we want an instance of the <tt>'data'</tt> module. Notice that
  76  a <b>semicolon</b> at the end of the line <b>suppresses the output</b>.
  77  
  78  <com:TTextHighlighter Language="cli" CssClass="source">
  79  >> $app = Prado::getApplication();
  80  
  81  >> $db = $app->getModule('data');
  82  </com:TTextHighlighter>
  83  Lastly, we want to use the data module to query for a post with <tt>ID=1</tt>. Notice that
  84  we <b>leave out the semicolon</b> to show the results.
  85  <com:TTextHighlighter Language="cli" CssClass="source">
  86  >> $db->queryPostByID(1)
  87  </com:TTextHighlighter>
  88  There should not be any errors and you should see the following. 
  89  <com:TTextHighlighter Language="cli" CssClass="source">
  90  PostRecord#1
  91  (
  92      [ID] => 1
  93      [AuthorID] => 1
  94      [AuthorName] => 'Prado User'
  95      [CreateTime] => 1148819691
  96      [ModifyTime] => 0
  97      [Title] => 'Welcome to Prado Weblog'
  98      [Content] => 'Congratulations! You have successfully installed Prado Blog --
  99   a PRADO-driven weblog system. A default administrator account has been created.
 100   Please login with <b>admin/prado</b> and update your password as soon as possible.'
 101      [Status] => 0
 102      [CommentCount] => 0
 103  )
 104  </com:TTextHighlighter>
 105  </p>
 106  </com:TContent>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7