Yii 2:AngularJS 的目录结构?

2023-10-15php开发问题
1

本文介绍了Yii 2:AngularJS 的目录结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的 Yii 2 应用程序的目录结构应该是什么?使用 Yii 2 视图真的有意义吗,还是我必须创建一个 AngularJS 应用程序目录并将 Yii 应用程序放在它的一个文件夹中?

What should the directory structure of my Yii 2 application be? Does it really makes sense to use Yii 2 views or do I have to create an AngularJS application directory and put the Yii application in one of its folders?

解释是什么?

推荐答案

我建议您将后端 (Yii 2) 和前端 (AngularJS) 分成两个单独的文件夹.死苍蝇和肉丸应分开食用.Yii 2 只提供服务器 API,而 AngularJS 做所有其他事情.

I recommend you to split your backend (Yii 2) and frontend (AngularJS) in two separate folders. Dead flies and meatballs should be served separately. Yii 2 just provides the server API, while AngularJS does all other things.

project/
  backend/        // Yii2 app
    web/          // Public visible backend folder
      index.php   // Entry point
    config/
    controllers/
    models/
    ...
  frontend/
    app/          // Your AngularJS application here
      css/        // Styles (.less or .css)
      img/        // Images
      lib/        // Third-party libraries such as jQuery or AngularJS
      js/         // .js files (controllers, services, etc.)
      partials/   // Templates (.html)
      index.html
    tests/        // AngularJS tests
    node_modules/
    ...

Web 服务器应该这样配置:

The web server should be configured this way:

  • http://mycoolsite.com/api/* 请求 project/backend/web/;
  • http://mycoolsite.com/* 请求 project/frontend/app/.
  • http://mycoolsite.com/api/* requests to project/backend/web/;
  • http://mycoolsite.com/* requests to project/frontend/app/.

如果您使用 Apache 作为网络服务器,mod_alias 可以提供帮助你.

If you use Apache as a web server, mod_alias can help you.

请注意,backendfrontend 目录中的文件夹结构可能会有所不同.

Note, that the folder structure inside the backend or frontend directory may vary.

  • 对于后端,这取决于您喜欢哪种模板(基本或高级).在我的示例中,我使用了基本的.
  • 对于 frontend,这取决于您的 AngularJS 应用程序组织.在示例中,我使用了 AngularJS 教程应用程序,但对于大型应用程序,最好使用 模块化结构.
  • For backend it depends on which template you prefer (basic or advanced). In my example I used the basic one.
  • For frontend it depends on your AngularJS application organization. In the example I used the AngularJS Tutorial App, but for huge applications it is better to use a modular structure.

这篇关于Yii 2:AngularJS 的目录结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17