Make an app with an API or not? - Laravel

So. I went on a trip to study Laravel in the last couple of weeks and fully enjoy it.

It's time to redesign the site, and I thought it was time to pull up some of our features, so I'm making the transition from CodeIgniter to Laravel.

I was wondering if it was worth starting from the RESTful API level in Laravel (simple enough to create) and using it as a base even for a web application. In the future, we are likely to create a mobile application that will have to use the API. So:

  • Should I connect a web application to the API
  • and what is the easiest way to make API calls without having to write a bazillion line for cURL every time I want to make a request?
+4
source share
3 answers

It is definitely worth it.

I am currently redesigning the dirty PHP code for the hosting company I created, turning it into beautiful Laravel code. I already have a mobile application working with it - Laravel makes it easy to return JSON data with a single line -

Response::json('OK', 200); 

or

 Response::eloquent(Auth::user()); 

or

 $tasks = Task::all(); Response::eloquent($tasks); 

You do not need to use CURL as far as I know. You can do all the queries with simple AJAX, jQuery will simplify this.

In addition, using some MVC JS framework will help you make the application code structure more elegant for the client side, and the advantage is that you can easily pack it into PhoneGap when you're ready for your API to do some real testing.

Today I posted a simple example on my blog that you can try to see if this approach suits your time: http://maxoffsky.com/code-blog/login-to-laravel-web-application-from-phonegap-or -backbone /

Check it and accept the answer if you think it is correct.

+4
source

As always, your results may vary, but this is exactly what I am experiencing right now. I am migrating a large .Net site with this API architecture, and I decided to keep it for Laravel.

I personally decided for this because:

  • More scalable. I can configure api.domain.com and then add additional box / vm / whatever as our traffic grows. In fact, you can load balance only api using "round robin" or several dns entries for this domain.

  • Future verification of new sites and applications. It looks like you are in the same situation. I see that an application or two will be added next year or so.

  • Lost value. You are already planning your controllers, so it may just be a matter of installing RESTful and setting to host.

To be fair, some counter points:

  • Additional loading time may be required, from processing through the API, although this should be minimal.

  • Additional security features to consider if you want to block access to your application.

Anyway, welcome to Laravel!

+1
source

and what is the easiest way / s to make API calls without having to write bazillion strings for cURL every time I want to make a request?

@Sneaksta try decrypting the chronometric e-mail message to call the leisure services. You can create forms in this extension and transfer data from these forms to you. Rest services https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?utm_source=chrome-ntp-icon

0
source

All Articles