Organizing files of a website powered by PHP, Smarty, JavaScript, MySQL

╄→гoц情女王★ 提交于 2019-11-27 19:05:37

问题


I am writing an web application powered by PHP, Smarty, JavaScript, CSS, MySQL.

There will be some classes, which will be used through out the application. There will be some scripts which will use those classes.

Any good article, tutorial, architecture on how to organize files for a web site?

P.S. It should contain how to organize all the files (PHP, JavaScript, CSS, template files.)


回答1:


Just remember PHP libraries and template files should not be directly accessible over the web server.

You can make class names like My_Db_Table and load them with __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



回答2:


Here are two good articles on PHP projects using Smarty and how to setup the file structure for them:

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




回答3:


A very basic folder layout:

root
 |
 |- htdocs       # apache documentroot (i.e. index.php etc.) here
 |   |
 |   |- styles   # css here
 |   |
 |   |- images
 |
 |- application  # classes etc. here
 |
 |- vendor
 |   |
 |   |- smarty   # smarty library files


来源:https://stackoverflow.com/questions/434724/organizing-files-of-a-website-powered-by-php-smarty-javascript-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!