Yii的2:目录结构与AngularJS? [英] Yii 2: directory structure with AngularJS?
问题描述
我应该我的Yii&NBSP的目录结构;二是应用?难道它真的有意义的使用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/
...
该网站的服务器应该这样配置:
The web server should be configured this way:
-
http://mycoolsite.com/api/*
要求项目/后端/ WEB /
; -
http://mycoolsite.com/*
要求项目/前端/应用/
。
http://mycoolsite.com/api/*
requests toproject/backend/web/
;http://mycoolsite.com/*
requests toproject/frontend/app/
.
如果您使用Apache作为Web服务器, mod_alias中可以帮助你。
If you use Apache as a web server, mod_alias can help you.
请注意,该后端里面的文件夹结构
或前端
目录可能会有所不同。
Note, that the folder structure inside the backend
or frontend
directory may vary.
- 对于
后台
这取决于哪个模板preFER(基本或高级)。在我的例子中,我使用的基本之一。 - 对于
前端
这取决于你的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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!