1
0
mirror of https://github.com/php/doc-fr.git synced 2026-03-24 07:02:06 +01:00
Files
archived-doc-fr/reference/yaf/tutorials.xml
Louis-Arnaud a0a454bcb4 Correction de ~150 fautes d'orthographe et de grammaire (#2546)
Élisions manquantes (de/le/que + voyelle), accords genre/nombre, conjugaisons incorrectes (on + 2e personne), typos, accents manquants, contractions (à le → au, de les → des), c.-à-d., etc.
2026-02-25 15:37:03 +01:00

177 lines
3.7 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
l'application ; il faut rediriger toutes les requêtes vers ce fichier.
(Il est possible d'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>Contrôleur 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>
il est aussi possible de 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
-->