Support the ongoing development of Laravel.io →
posted 2 years ago
API
0

Let's simplify building an API in Laravel terms (and I assume a RESTful API).

Create a route:

Route::get('/pokemon', function () {
    //
});

Return some data:

Route::get('/pokemon', function () {
    return ['Bulbasaur', 'Charmander', 'Squirtle'];
});

Then, when you hit http://localhost/pokemon in your web browser, you'll see this (in the JSON format):

['Bulbasaur', 'Charmander', 'Squirtle']

This is an API is its simplest form.

Makes sense?

Now let's say someone is trying to build a Pokedex. This person could use your (RESTful) API to display the data it provides.

Still makes sense? Let me know.

— Benjamin from Larabiz (Découvrez les bases du routing)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

rey rey Joined 30 Aug 2022

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.