1 / 7

BUILDING RESTFUL APIS WITH LARAVEL

Within a short span of time, RESTful APIs have become an integral part of website and web application development. While developing web services, most web developers nowadays opt for these application programming interfaces (APIs) developed based on REpresentational State Transfer (REST) architectural style.

Download Presentation

BUILDING RESTFUL APIS WITH LARAVEL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BUILDING RESTFUL APIS WITH LARAVEL

  2.  Within a short span of time, RESTful APIs have become an integral part of website and web application development.  While developing web services, most web developers nowadays opt for these application programming interfaces (APIs) developed based on REpresentational State Transfer (REST) architectural style.  Unlike conventional architectural styles, RESTful API facilitates data exchange between web applications through an open and stateless protocol – HTTP. It further uses HTTP requests to GET, PUT, POST, and DELETE data.

  3.  The web developers can write RESTful APIs in a number of programming languages including PHP and various PHP Frameworks.  Here is a brief comparison of various PHP Frameworks. Though one of the youngest ones, Laravel has emerged as a good framework for PHP developers to work in the recent years. The PHP programmers can build RESTful APIs using Laravel.  Laravel simplifies development and testing of RESTful APIs by providing a number of robust features – real-time communication, job queue, and API authentication.  But you, as a PHP programmer, must follow a sequence of steps in building Restful APIs with Laravel quickly.

  4. Important Steps in Building RESTful APIs with Laravel Know Appropriate Use of HTTP Verbs As noted earlier, RESTful APIs leverage a number of request methods defined by HTTP. You have to use the specific HTTP verbs to perform the desired action on specific resources. Hence, you must understand the use of important HTTP verbs – GET, POST, PUT and DELETE clearly. While developing a RESTful API with Laravel, create resources through POST and retrieve resources through GET. At the same time, you have to use PUT to update resources and DELETE to remove resources. It is always important to use the HTTP verbs in the most appropriate way.

  5. Set up Laravel Framework If you are yet to install Laravel, it is advisable to install the web framework through the robust PHP dependency manager – Composer. After installing Laravel on a development server, you need to spend some time to understand its folder structure. The features provided by Laravel will enable you to create simple RESTful APIs without putting extra time and effort.

  6. Add Endpoints that Respond to Specific HTTP Verbs You can use Closures to create end points for various resources by modifying the app/routes.php file. You can even follow the same procedure to create additional end points that respond to GET requests. Also, you can make the end points respond to PUT requests simply by replacing Route::get with Route::post. Similarly, you can create end points that respond to other HTTP methods simply by specifying the exact Route. Laravel even allows you to create end points that do not respond to any specific HTTP methods.

  7. Content Designed By : Mindfire Solutions

More Related