【问题标题】:Organizing files of a website powered by PHP, Smarty, JavaScript, MySQL组织由 PHP、Smarty、JavaScript、MySQL 提供支持的网站的文件
【发布时间】:2010-09-30 21:18:20
【问题描述】:

我正在编写一个由 PHP、Smarty、JavaScript、CSS、MySQL。

将有一些类,将在整个应用程序中使用。 会有一些脚本会使用这些类。

关于如何组织网站文件的任何好的文章、教程和架构?

附:它应该包含如何组织所有文件(PHP、JavaScript、CSS、模板文件。)

【问题讨论】:

    标签: php javascript css smarty


    【解决方案1】:

    这里有两篇关于使用 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

    【讨论】:

      【解决方案2】:

      一个非常基本的文件夹布局:

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

      【讨论】:

        【解决方案3】:

        请记住 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
        

        【讨论】:

        • 我建议在同一个子文件夹中包含 CSS 和静态图像。这意味着在 CSS 中使用任何 url() 都不需要路径。 CSS 内部对外部资源的引用是相对于 CSS 文件本身而言的;不是原始的 HTML。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-10
        • 1970-01-01
        • 1970-01-01
        • 2016-06-22
        • 1970-01-01
        相关资源
        最近更新 更多