summaryrefslogtreecommitdiff
path: root/zend/documentation/manual/core/en/project-structure.project.html
blob: 0cb10ab492ef771eed51450fa4db75a631708d86 (plain)
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Recommended Project Directory Structure - Zend Framework Manual</title>

</head>
<body>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="project-structure.overview.html">Overview</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="project-structure.html">Recommended Project Structure for Zend Framework MVC Applications</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="project-structure.filesystem.html">Module Structure</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="project-structure.project" class="section"><div class="info"><h1 class="title">Recommended Project Directory Structure</h1></div>
        

        <div class="programlisting text"><div class="textcode"><div class="text" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;project name&gt;/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; application/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; configs/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; application.ini</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; controllers/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; helpers/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; forms/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; layouts/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filters/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; helpers/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scripts/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; models/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; modules/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; services/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; views/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filters/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; helpers/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scripts/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Bootstrap.php</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; data/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; cache/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; indexes/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; locales/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; logs/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; sessions/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; uploads/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; docs/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; library/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; css/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; images/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; js/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; .htaccess</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; index.php</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; scripts/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; jobs/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; build/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; temp/</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; tests/</div></li></ol></div></div></div>


        <p class="para">
            The following describes the use cases for each directory as listed.
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">application/</var></em>: This directory contains
                    your application. It will house the <acronym class="acronym">MVC</acronym> system, as well as
                    configurations, services used, and your bootstrap file.
                </p>

                <ul class="itemizedlist">
                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">configs/</var></em>: The
                            application-wide configuration directory.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">controllers/</var></em>,
                            <em class="emphasis"><var class="filename">models/</var></em>, and
                            <em class="emphasis"><var class="filename">views/</var></em>: These directories
                            serve as the default controller, model or view directories. Having
                            these three directories inside the application directory provides the
                            best layout for starting a simple project as well as starting a modular
                            project that has global <var class="filename">controllers/models/views</var>.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">controllers/helpers/</var></em>: These
                            directories will contain action helpers. Action helpers will be
                            namespaced either as &quot;<span class="classname">Controller_Helper_</span>&quot; for
                            the default module or &quot;&lt;Module&gt;_Controller_Helper&quot; in other
                            modules.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">layouts/</var></em>: This layout
                            directory is for <acronym class="acronym">MVC</acronym>-based layouts. Since
                            <span class="classname">Zend_Layout</span> is capable of
                            <acronym class="acronym">MVC</acronym>- and non-<acronym class="acronym">MVC</acronym>-based layouts,
                            the location of this directory reflects that layouts are not on a
                            1-to-1 relationship with controllers and are independent of templates
                            within <var class="filename">views/</var>.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">modules/</var></em>: Modules allow a
                            developer to group a set of related controllers into a logically
                            organized group. The structure under the modules directory would
                            resemble the structure under the application directory.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">services/</var></em>: This directory is
                            for your application specific web-service files that are provided by
                            your application, or for implementing a <a href="http://www.martinfowler.com/eaaCatalog/serviceLayer.html" class="link external">&raquo; Service
                                Layer</a> for your models.
                        </p>
                    </li>

                    <li class="listitem">
                        <p class="para">
                            <em class="emphasis"><var class="filename">Bootstrap.php</var></em>: This file is
                            the entry point for your application, and should implement
                            <span class="classname">Zend_Application_Bootstrap_Bootstrapper</span>.
                            The purpose for this file is to bootstrap the application and make
                            components available to the application by initializing them.
                        </p>
                    </li>
                </ul>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">data/</var></em>: This directory provides a
                    place to store application data that is volatile and possibly temporary. The
                    disturbance of data in this directory might cause the application to fail.
                    Also, the information in this directory may or may not be committed to a
                    subversion repository. Examples of things in this directory are session files,
                    cache files, sqlite databases, logs and indexes.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">docs/</var></em>: This directory contains
                    documentation, either generated or directly authored.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">library/</var></em>: This directory is for
                    common libraries on which the application depends, and should be on the
                    <acronym class="acronym">PHP</acronym> <span class="property">include_path</span>. Developers should
                    place their application&#039;s library code under this directory in a unique
                    namespace, following the guidelines established in the <acronym class="acronym">PHP</acronym>
                    manual&#039;s <a href="http://www.php.net/manual/en/userlandnaming.php" class="link external">&raquo; Userland Naming
                        Guide</a>, as well as those established by Zend itself. This
                    directory may also include Zend Framework itself; if so, you would house it in
                    <var class="filename">library/Zend/</var>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">public/</var></em>: This directory contains all
                    public files for your application. <var class="filename">index.php</var> sets up and
                    invokes <span class="classname">Zend_Application</span>, which in turn invokes the
                    <var class="filename">application/Bootstrap.php</var> file, resulting in dispatching
                    the front controller. The web root of your web server would typically be set to
                    this directory.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">scripts/</var></em>: This directory contains
                    maintenance and/or build scripts. Such scripts might include command line,
                    cron, or phing build scripts that are not executed at runtime but are part of
                    the correct functioning of the application.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">temp/</var></em>: The <var class="filename">temp/</var>
                    folder is set aside for transient application data. This information would not
                    typically be committed to the applications svn repository. If data under the
                    <var class="filename">temp/</var> directory were deleted, the application should be
                    able to continue running with a possible decrease in performance until data is
                    once again restored or recached.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"><var class="filename">tests/</var></em>: This directory contains
                    application tests. These could be hand-written, PHPUnit tests, Selenium-RC
                    based tests or based on some other testing framework. By default, library code
                    can be tested by mimicing the directory structure of your
                    <var class="filename">library/</var> directory. Additionally, functional tests for
                    your application could be written mimicing the
                    <var class="filename">application/</var> directory structure (including the
                    application subdirectory).
                </p>
            </li>
        </ul>
    </div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="project-structure.overview.html">Overview</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="project-structure.html">Recommended Project Structure for Zend Framework MVC Applications</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="project-structure.filesystem.html">Module Structure</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="project-structure.html">Recommended Project Structure for Zend Framework MVC Applications</a></li>
  <li><a href="project-structure.overview.html">Overview</a></li>
  <li class="active"><a href="project-structure.project.html">Recommended Project Directory Structure</a></li>
  <li><a href="project-structure.filesystem.html">Module Structure</a></li>
  <li><a href="project-structure.rewrite.html">Rewrite Configuration Guide</a></li>
 </ul>
 </td>
    </tr>
</table>
</body>
</html>