-
Notifications
You must be signed in to change notification settings - Fork 70
/
tutorials.xml
178 lines (161 loc) · 4.01 KB
/
tutorials.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 198f577cb09d61622267f7480b7ec180c7d714da Maintainer: irker 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>Классический пример каталога для приложения</title>
<screen>
<![CDATA[
- index.php
- .htaccess
+ conf
|- application.ini //Файл настроек
- application/
- Bootstrap.php
+ controllers
- Index.php //Контроллер по умолчанию
+ views
|+ index
- index.phtml //Шаблон вывода для действия по умолчанию
+ modules
- library
- models
- plugins
]]>
</screen>
</example>
<example>
<title>Введение</title>
<para>
Файл index.php — единственная точка входа в приложение,
все запросы необходимо направлять через этот файл (например, через файл .htaccess в связке 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() // Выполнение методов, которые определили в файле Bootstrap.php
->run()
;
?>
]]>
</programlisting>
</example>
<example>
<title>Правила перенаправления</title>
<screen>
<![CDATA[
#для apache (.htaccess)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
#для 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;
}
}
#для lighttpd
$HTTP["host"] =~ "(www.)?domain.com$" {
url.rewrite = (
"^/(.+)/?$" => "/index.php/$1",
)
}
]]>
</screen>
</example>
<example>
<title>Конфигурация приложения</title>
<programlisting role="ini">
<![CDATA[
[yaf]
;APPLICATION_PATH должна быть определена в index.php
application.directory=APPLICATION_PATH "/application/"
;product секция должна наследовать yaf
[product:yaf]
foo=bar
]]>
</programlisting>
</example>
<example>
<title>Контроллер по умолчанию</title>
<programlisting role="php">
<![CDATA[
<?php
class IndexController extends Yaf_Controller_Abstract
{
/* действие по умолчанию */
public function indexAction()
{
$this->_view->word = "hello world";
// или
// $this->getView()->word = "hello world";
}
}
?>
]]>
</programlisting>
</example>
<example>
<title>Шаблон вывода по умолчанию</title>
<programlisting role="php">
<![CDATA[
<html>
<head>
<title>Привет, мир!</title>
</head>
<body>
<?php echo $word; ?>
</body>
</html>
]]>
</programlisting>
</example>
<example>
<title>Запуск приложения</title>
&example.outputs.similar;
<screen>
<![CDATA[
<html>
<head>
<title>Hello World</title>
</head>
<body>
Привет, Мир!
</body>
</html>
]]>
</screen>
<note>
<para>
Приведённый пример можно также создать через генератор кода Yaf,
который можно найти здесь 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
-->