mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 07:22:16 +01:00
173 lines
3.6 KiB
XML
173 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 198f577cb09d61622267f7480b7ec180c7d714da Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: no Maintainer: andresdzphp -->
|
|
|
|
<chapter xml:id="yaf.tutorials" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
|
|
<example>
|
|
<title>Distribución clásica del directorio Application</title>
|
|
<screen>
|
|
<![CDATA[
|
|
- index.php
|
|
- .htaccess
|
|
+ conf
|
|
|- application.ini //configuración de la aplicación
|
|
- application/
|
|
- Bootstrap.php
|
|
+ controllers
|
|
- Index.php //controlador predeterminado
|
|
+ views
|
|
|+ index
|
|
- index.phtml //plantilla de vistas para la acción predeterminada
|
|
+ modules
|
|
- library
|
|
- models
|
|
- plugins
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Entrada</title>
|
|
<para>index.php en el directorio superior es la única forma de entrada de la aplicación, se deberían reescribir todas las peticiones al mismo (se puede emplear .htaccess de 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() //llamar a los métodos de arranque definidos en Bootstrap.php
|
|
->run();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Regla de sobrescritura</title>
|
|
<screen>
|
|
<![CDATA[
|
|
#para apache (.htaccess)
|
|
RewriteEngine On
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteRule .* index.php
|
|
|
|
#para 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;
|
|
}
|
|
}
|
|
|
|
#para lighttpd
|
|
$HTTP["host"] =~ "(www.)?domain.com$" {
|
|
url.rewrite = (
|
|
"^/(.+)/?$" => "/index.php/$1",
|
|
)
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Configuración de la aplicación</title>
|
|
<programlisting role="ini">
|
|
<![CDATA[
|
|
[yaf]
|
|
;APPLICATION_PATH es la constante definida en index.php
|
|
application.directory=APPLICATION_PATH "/application/"
|
|
|
|
;la sección 'product' hereda de las sección 'yaf'
|
|
[product:yaf]
|
|
foo=bar
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Controlador predeterminado</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class IndexController extends Yaf_Controller_Abstract {
|
|
/* acción predeterminada */
|
|
public function indexAction() {
|
|
$this->_view->word = "hola mundo";
|
|
//or
|
|
// $this->getView()->word = "hola mundo";
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Plantilla de vistas predeterminada</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<html>
|
|
<head>
|
|
<title>Hola Mundo</title>
|
|
</head>
|
|
<body>
|
|
<?php echo $word;?>
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Ejecutar la aplicación</title>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
<html>
|
|
<head>
|
|
<title>Hola Mundo</title>
|
|
</head>
|
|
<body>
|
|
hola mundo
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</screen>
|
|
<note>
|
|
<para>
|
|
También se puede generar el ejemplo de arriba usando el generado de código de Yaf, el cual
|
|
se puede encontrar en 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
|
|
-->
|