mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-24 17:02:18 +01:00
177 lines
3.6 KiB
XML
177 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 198f577cb09d61622267f7480b7ec180c7d714da Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<chapter xml:id="yaf.tutorials" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
|
|
<example>
|
|
<title>Une architecture classique d'une application</title>
|
|
<screen>
|
|
<![CDATA[
|
|
- index.php
|
|
- .htaccess
|
|
+ conf
|
|
|- application.ini //configuration de l'application
|
|
- application/
|
|
- Bootstrap.php
|
|
+ controllers
|
|
- Index.php // contrôleur par défaut
|
|
+ views
|
|
|+ index
|
|
- index.phtml //template d'affichage pour l'action par défaut
|
|
+ modules
|
|
- library
|
|
- models
|
|
- plugins
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Entry</title>
|
|
<para>
|
|
index.php dans le premier dossier est le seul point d'entrée de
|
|
votre application ; vous devez re-diriger toutes les requêtes vers ce fichier.
|
|
(Vous pouvez utiliser un fichier .htaccess avec Apache + php_mod.)
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
define("APPLICATION_PATH", dirname(__FILE__));
|
|
|
|
$app = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
|
|
$app->bootstrap() //appel des méthodes bootstrap définies dans le fichier Bootstrap.php
|
|
->run();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Règle de ré-écriture des requêtes</title>
|
|
<screen>
|
|
<![CDATA[
|
|
#for apache (.htaccess)
|
|
RewriteEngine On
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteRule .* index.php
|
|
|
|
#for nginx
|
|
server {
|
|
listen ****;
|
|
server_name domain.com;
|
|
root document_root;
|
|
index index.php index.html index.htm;
|
|
|
|
if (!-e $request_filename) {
|
|
rewrite ^/(.*) /index.php$1 last;
|
|
}
|
|
}
|
|
|
|
#for lighttpd
|
|
$HTTP["host"] =~ "(www.)?domain.com$" {
|
|
url.rewrite = (
|
|
"^/(.+)/?$" => "/index.php/$1",
|
|
)
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Configuration de l'application</title>
|
|
<programlisting role="ini">
|
|
<![CDATA[
|
|
[yaf]
|
|
;APPLICATION_PATH est la constante définie dans index.php
|
|
application.directory=APPLICATION_PATH "/application/"
|
|
|
|
;section de production héritée de la section yaf
|
|
[product:yaf]
|
|
foo=bar
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Controlleur par défaut</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class IndexController extends Yaf_Controller_Abstract {
|
|
/* action par défaut */
|
|
public function indexAction() {
|
|
$this->_view->word = "hello world";
|
|
// ou
|
|
// $this->getView()->word = "hello world";
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Template de rendu par défaut</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<html>
|
|
<head>
|
|
<title>Hello World</title>
|
|
</head>
|
|
<body>
|
|
<?php echo $word;?>
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Exécution de l'application</title>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
<html>
|
|
<head>
|
|
<title>Hello World</title>
|
|
</head>
|
|
<body>
|
|
hello world
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</screen>
|
|
<note>
|
|
<para>
|
|
vous pouvez aussi générer l'exemple ci-dessus en utilisant un
|
|
générateur de code Yaf, qui peut être trouvé sur
|
|
yaf@github.
|
|
</para>
|
|
</note>
|
|
</example>
|
|
|
|
</chapter>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|