建议的文件结构


Recommended file structure

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

我目前的设置是这样的

  • 索引.html = 单数起点
  • 应用程序接口/
    • 索引.php = 纤细起点
    • .htaccess = 将 http://domain/api/* 重定向到索引.php
    • (保留PHP slim API的文件夹和文件)
  • .app/
    • app.modules.js, app.routes.js = main js angular
    • (保留Angular网站的文件夹和文件)
  • 供应商/
  • node_modules/
  • bower_modules/
  • packages.json, composer.json, gulpfile.js = tools 的配置文件

它按照我想要的方式工作:索引.html启动角度网站,我所有的 api 调用都在"http://domain/api/*"下,但它看起来很混乱,我找不到这个项目更好的结构。

一种解决方案是将供应商、node_modules和bower_modules存储在"public_html"的文件夹中,并在"public_html"中只保留索引.html、应用程序和 api,但我无法在我的主机中做到这一点。

你可以跳过后端和前端文件夹,从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