Search code examples
phpajaxlaravel-spark

Laravel Spark for an API based (AJAX) web service?


A question: Will Laravel Spark be suitable as the boilerplate for an SaaS app that uses AJAX implementation?

It seems nowadays the best way to start building a new web service is to choose such architecture that the backend is used as API for the front-end application. And if you are using for example AngularJS as the front-end framework, you can then rather quickly bundle it as an mobile by using Ionic. You would also need to have responsive web application to have the same codebase to adopt to mobile device's screen widths.


Solution

  • If you don't mind using vue.js as your framework then you'll have everything already set, you can just open the editor and start adding your code. Spark has a nice feature that it will allow you out-of-box to consume the same API both through web interface (ajax) authenticated by cookies, and from another client authenticated by tokens. It takes care of all security and stuff and it all works very nice without any additional setup. Just add your api routes, templates and some vue components and Spark will take care of the rest.

    If you don't want to use VueJS, then it's significantly more work to make the same functionality. If you need payments and settings (and you probably do) Spark will still save you a lot of time, but will also give you trouble when you try to integrate the Settings area (which is implemented in Vue) with the rest of your code. You will constantly find yourself work around & against it's presumptions.

    Spark is well-written and modular, but still it's far from trivial to switch to the js framework, so it's better to stick to the VueJS, if possible.