| 1 |
lars |
1 |
<com:TContent ID="body" >
|
|
|
2 |
<h1 id="501">Outil en ligne de commande</h1>
|
|
|
3 |
<p id="70046" class="block-content">Le script optionnel <tt>prado-cli.php</tt> du répertoire <tt>framework</tt> est un outil en ligne de commande destiné à éxecuter certaines tâches dans PRADO.
|
|
|
4 |
Le script <tt>prado-cli.php</tt> peut être utilisé pour créer le squelette de projet PRADO, des fichiers tests et accéder à un shell interactif PHP.
|
|
|
5 |
</p>
|
|
|
6 |
<h2 id="502">Pré-requis</h2>
|
|
|
7 |
<p id="70047" class="block-content">
|
|
|
8 |
Afin d'utiliser l'outil en ligne de commande, vous aurez à utiliser une console. De plus, PHP doit être capable d'éxecuter des scripts en ligne de commande.
|
|
|
9 |
</p>
|
|
|
10 |
|
|
|
11 |
<h2 id="503">Utilisation</h2>
|
|
|
12 |
<p id="70048" class="block-content">
|
|
|
13 |
Si vous tapez <tt>php chemin/vers/framework/prado-cli.php</tt>, vous devez voir les informations suivantes. Alternativement, si vous n'êtes pas sous Windows, vous pouvez essayer de transformer le fichier <tt>prado-cli.php</tt> en un éxecutable</p>
|
|
|
14 |
<com:TTextHighlighter Language="cli" CssClass="source block-content" id="code_70006">
|
|
|
15 |
Command line tools for Prado 3.0.5.
|
|
|
16 |
usage: php prado-cli.php action <parameter> [optional]
|
|
|
17 |
example: php prado-cli.php -c mysite
|
|
|
18 |
|
|
|
19 |
actions:
|
|
|
20 |
-c <directory>
|
|
|
21 |
Creates a Prado project skeleton for the given <directory>.
|
|
|
22 |
|
|
|
23 |
-t <directory>
|
|
|
24 |
Create test fixtures in the given <directory>.
|
|
|
25 |
|
|
|
26 |
shell [directory]
|
|
|
27 |
Runs a PHP interactive interpreter. Initializes the Prado
|
|
|
28 |
application in the given [directory].
|
|
|
29 |
</com:TTextHighlighter>
|
|
|
30 |
|
|
|
31 |
<p id="70049" class="block-content">Les <b><parameter></b> sont les paramètres requis et <b>[optional]</b>
|
|
|
32 |
désignent les paramètres optionnels. </p>
|
|
|
33 |
|
|
|
34 |
<h2 id="504">Créer un nouveau squelette de projet PRADO</h2>
|
|
|
35 |
|
|
|
36 |
<p id="70050" class="block-content">Afin de créer un squelettre de projet PRADO, suivez les instructions suivantes :</p>
|
|
|
37 |
<ol>
|
|
|
38 |
<li>Placez-vous dans le dossier où vous souhaitez créer le projet.</li>
|
|
|
39 |
<li>Tapez, <tt>php ../prado/framework/prado-cli.php -c helloworld</tt>, où
|
|
|
40 |
<tt>helloworld</tt> est le nom du dossier où vous souhaitez créer le squelette.</li>
|
|
|
41 |
<li>Tapez, <tt>php ../prado/framework/prado-cli.php <b>-t</b> helloworld</tt> afin de créer les fichiers tests du projet <tt>helloworld</tt>.</li>
|
|
|
42 |
</ol>
|
|
|
43 |
|
|
|
44 |
<h2 id="505">Shell interactif</h2>
|
|
|
45 |
<p id="70051" class="block-content">
|
|
|
46 |
Le shell interactif vous permet d'évaluer des scripts PHP directement en ligne de commande.
|
|
|
47 |
Le script <tt>prado-cli.php</tt> peut être utilisé pour démarrer le shell et charger un projet PRADO existant.
|
|
|
48 |
Par exemple, chargons le projet de démo blog. En supposant que votre console se situe actuellement dans le répertoire <tt>prado</tt> de la distribution, tapez :
|
|
|
49 |
</p>
|
|
|
50 |
<p id="70052" class="block-content">
|
|
|
51 |
<com:TTextHighlighter Language="cli" CssClass="source block-content" id="code_70007">
|
|
|
52 |
$: php framework/prado-cli.php shell demos/blog
|
|
|
53 |
</com:TTextHighlighter>
|
|
|
54 |
Le résultat doit être
|
|
|
55 |
<com:TTextHighlighter Language="cli" CssClass="source block-content" id="code_70008">
|
|
|
56 |
Command line tools for Prado 3.0.5.
|
|
|
57 |
** Loaded Prado application in directory "demos\blog\protected".
|
|
|
58 |
PHP-Shell - Version 0.3.1
|
|
|
59 |
(c) 2006, Jan Kneschke <jan@kneschke.de>
|
|
|
60 |
|
|
|
61 |
>> use '?' to open the inline help
|
|
|
62 |
|
|
|
63 |
>>
|
|
|
64 |
</com:TTextHighlighter>
|
|
|
65 |
Ensuite, nous allons appeler une instance de l'application du blog PRADO, et de cette instance nous allons créer une instance du module<tt>'data'</tt>. Notez qu'un <b>point-virgule</b> à la fin de la ligne <b>n'affiche pas la sortie</b>.
|
|
|
66 |
|
|
|
67 |
<com:TTextHighlighter Language="cli" CssClass="source block-content" id="code_70009">
|
|
|
68 |
>> $app = Prado::getApplication();
|
|
|
69 |
|
|
|
70 |
>> $db = $app->getModule('data');
|
|
|
71 |
</com:TTextHighlighter>
|
|
|
72 |
Pour finir, nous voulons utiliser le module 'data' pour récupérer le post ayant l'<tt>ID=1</tt>. Notez que nous <b>n'avons pas mis de point-virgule</b> afin de voir le résultat de la commande.
|
|
|
73 |
<com:TTextHighlighter Language="cli" CssClass="source block-content" id="code_70010">
|
|
|
74 |
>> $db->queryPostByID(1)
|
|
|
75 |
</com:TTextHighlighter>
|
|
|
76 |
Aucune erreur ne doit se produire et vous devez dorénavant voir :
|
|
|
77 |
<com:TTextHighlighter Language="cli" CssClass="source block-content" id="code_70011">
|
|
|
78 |
PostRecord#1
|
|
|
79 |
(
|
|
|
80 |
[ID] => 1
|
|
|
81 |
[AuthorID] => 1
|
|
|
82 |
[AuthorName] => 'Prado User'
|
|
|
83 |
[CreateTime] => 1148819691
|
|
|
84 |
[ModifyTime] => 0
|
|
|
85 |
[Title] => 'Welcome to Prado Weblog'
|
|
|
86 |
[Content] => 'Congratulations! You have successfully installed Prado Blog --
|
|
|
87 |
a PRADO-driven weblog system. A default administrator account has been created.
|
|
|
88 |
Please login with <b>admin/prado</b> and update your password as soon as possible.'
|
|
|
89 |
[Status] => 0
|
|
|
90 |
[CommentCount] => 0
|
|
|
91 |
)
|
|
|
92 |
</com:TTextHighlighter>
|
|
|
93 |
</p>
|
|
|
94 |
<div class="last-modified">$Id: CommandLine.page 1650 2007-02-18 06:55:32Z mickymax $</div></com:TContent>
|