向PHP应用程序添加静态文件


Adding static files to PHP application

我将此作为应用程序的起点:https://github.com/panique/php-login-minimal

我的问题是,我把CSS、JS等放在哪里

这样做的正确方法是:

根文件夹

Application
    _installation
    classes
    config
    libraries
    views
    index.php
    register.php
public_html
    css
    js
    img

您的Application是否可以公开访问?如果没有,那么你的网站将无法工作。通常只有public_html可以作为网站的根访问,所以必须有index.php

如果Application是您的web根目录,那么public_html也可以从web访问,并且所有路径都设置为使用public_html中的css,那么就可以了


它的工作频率

你把所有东西都放在public_html

public_html
  /*
   * When going to www.example.com, you will be located
   * in this directory and viewing index.*
   */
  |- assets/
  |- css/
  |'
  | |- styles.css
  | |- ie7.css
  |- js/
  |'
  | |- jquery.min.js
  | |- scripts.css
  |- index.php
  |- src/
  |'
  | |- App/
  | '
  |  |- Controllers/
  |  |- Models
  |  |- /* other files */
framework
  /*
   * Accessible files only via system path "/var/www/html/framework..." 
   * Not able to access via http. www.example.com/framework will not work.
   */
  |- src/

你能按照你提到的那样做吗?它会很好地工作。