推荐的文件结构

时间:2016-03-18 02:50:40

标签: php angularjs composer-php file-structure

我正在寻找一个包含Angular前端和Php Slim Api的网站的起始文件结构。

我目前的设置就像

  • index.html = Sngular起点
  • API /
    • index.php =细长的起点
    • .htaccess =将http://domain/api/ *重定向到index.php
    • (保留php slim api的文件夹和文件)
  • 应用程序/
    • app.modules.js,app.routes.js = main js angular
    • (保留角网站的文件夹和文件)
  • 供应商/
  • node_modules /
  • bower_modules /
  • packages.json,composer.json,gulpfile.js =工具的配置文件

它按我的意愿工作:index.html启动角度网站,我所有的api调用都在" http://domain/api/ *"但它看起来很乱,我找不到更好的结构。

一种解决方案是将vendor,node_modules和bower_modules存储在' public_html'的文件夹中。并在' public_html'中留下index.html,app和api。但我无法在我的主人那里做到这一点。

1 个答案:

答案 0 :(得分:3)

你可以跳过后端和前端文件夹,然后从web(用于php)和app(用于angularjs)开始。但我建议有这些父文件夹,以防你需要额外的文件,比如所有的配置或脚本。

backend
 --web/          // Public visible backend folder
    -----index.php   // Entry point
    -----config/
    -----controllers/
    -----models/
frontend
--app/
    ----- shared/   // acts as reusable components or partials of our site
    ---------- sidebar/
    --------------- sidebarDirective.js
    --------------- sidebarView.html
    ---------- article/
    --------------- articleDirective.js
    --------------- articleView.html
    ----- components/   // each component is treated as a mini Angular app
    ---------- home/
    --------------- homeController.js
    --------------- homeService.js
    --------------- homeView.html
    ---------- blog/
    --------------- blogController.js
    --------------- blogService.js
    --------------- blogView.html
    ----- app.module.js
    ----- app.routes.js
    assets/
    ----- img/      // Images and icons for your app
    ----- css/      // All styles and style related files (SCSS or LESS files)
    ----- js/       // JavaScript files written for your app that are not for angular
    node_modules/
    bower_modules/Underscore, etc.
    index.html
相关问题