【发布时间】:2010-09-30 21:18:20
【问题描述】:
我正在编写一个由 PHP、Smarty、JavaScript、CSS、MySQL。
将有一些类,将在整个应用程序中使用。 会有一些脚本会使用这些类。
关于如何组织网站文件的任何好的文章、教程和架构?
附:它应该包含如何组织所有文件(PHP、JavaScript、CSS、模板文件。)
【问题讨论】:
标签: php javascript css smarty
我正在编写一个由 PHP、Smarty、JavaScript、CSS、MySQL。
将有一些类,将在整个应用程序中使用。 会有一些脚本会使用这些类。
关于如何组织网站文件的任何好的文章、教程和架构?
附:它应该包含如何组织所有文件(PHP、JavaScript、CSS、模板文件。)
【问题讨论】:
标签: php javascript css smarty
这里有两篇关于使用 Smarty 的 PHP 项目以及如何为它们设置文件结构的好文章:
http://codepoets.co.uk/php5_application_directory_structure_ruby_on_rails
http://www.edit-x.com/editx-support-articles.php?s=&c=21&d=48&e=&f=&g=&a=11122&w=2
【讨论】:
一个非常基本的文件夹布局:
root
|
|- htdocs # apache documentroot (i.e. index.php etc.) here
| |
| |- styles # css here
| |
| |- images
|
|- application # classes etc. here
|
|- vendor
| |
| |- smarty # smarty library files
【讨论】:
请记住 PHP 库和模板文件不应通过 Web 服务器直接访问。
您可以创建类似 My_Db_Table 的类名并使用 __autoload 加载它们。
/project
- /config
- /html
- - /css
- - /images
- - /js
- - /subdirs for php files unless you use apache mod_rewrite or similar
- - index.php
- - otherfiles.php
- /lib
- - /My
- - - /Db
- - - - Table.php
- /templates
- /functions
- /scripts
【讨论】: