Eja*_*rim 4 php angularjs yii2
我的Yii 2应用程序的目录结构应该是什么?使用Yii 2视图真的有意义还是我必须创建一个AngularJS应用程序目录并将Yii应用程序放在其中一个文件夹中?
解释是什么?
我建议你将后端(Yii 2)和前端(AngularJS)分成两个单独的文件夹.死苍蝇和肉丸应单独提供.Yii 2只提供服务器API,而AngularJS提供所有其他功能.
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/
...
Run Code Online (Sandbox Code Playgroud)
应该以这种方式配置Web服务器:
http://mycoolsite.com/api/*要求project/backend/web/;http://mycoolsite.com/*要求project/frontend/app/.如果您使用Apache作为Web服务器,mod_alias可以帮助您.
请注意,backend或frontend目录中的文件夹结构可能会有所不同.
backend它取决于您喜欢的模板(基本或高级).在我的例子中,我使用了基本的.frontend这取决于你的AngularJS应用程序的组织.在示例中,我使用了AngularJS教程应用程序,但对于大型应用程序,最好使用模块化结构.| 归档时间: |
|
| 查看次数: |
2575 次 |
| 最近记录: |