简体   繁体   English

使用Laravel 5构建Restfull Api

[英]Building an Restfull Api with Laravel 5

I'm planning to build an restfull api with laravel 5 for a client because they also want to make apps in the future (first ios/android, larer ios watch). 我计划使用laravel 5为客户端构建一个restfull api,因为他们也希望将来制作应用程序(第一款ios / android,更大的ios watch)。 For version 1.0 they only want a webversion of the site, so i'm planning to do that the traditional way with blade templating and laravel routing. 对于1.0版,他们只需要网站的webversion,因此我计划使用刀片模板和laravel路由的传统方式来实现。

Are there good practices for combining those 2? 是否有结合这两个的良好实践? The api routes will in some places be different then the routes i need for the 'normal' webversion, most of the services and repositories would also be the same. api路由在某些地方将不同于我为“正常” webversion所需的路由,大多数服务和存储库也将相同。 Output would to totally different because the api needs to return Json, where the 'normal' webversion would return Html. 输出将完全不同,因为api需要返回Json,而“正常” webversion将返回Html。

Any ideas? 有任何想法吗?

I would really consider not using Blade and using a front-end framework instead such as Angular. 我真的会考虑不使用Blade而是使用诸如Angular之类的前端框架。 If you can get to the point where your back-end is solely serving up JSON responses, it would make your life much easier down the road. 如果您可以达到后端仅提供JSON响应的地步,那么您的生活将变得更加轻松。

As an added benefit, a single page app would also be much more usable on a mobile device out of the box. 另外一个好处是,单页应用程序在开箱即用的移动设备上也将更加有用。

You could also look into PhoneGap as well. 您也可以研究PhoneGap。 If you have everything running on Angular, it shouldn't be too difficult to port it over to PhoneGap. 如果您在Angular上运行了所有程序,那么将其移植到PhoneGap并不难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM