Build an API with Laravel 5.7

Connor Leech
Employbl
Published in
7 min readDec 7, 2018

--

We’re hosting the Decemeber 2018 Laravel SF meetup at Stitch Labs. These are some show notes about installing Laravel and setting up an API.

If you’re new to Laravel, check out the Getting Started docs

Source code for this application.

Jump ahead: adding JWT auth

Laravel logo

1. Create a new Laravel app

$ composer update
$ composer global require laravel/installer
$ laravel new december-2018-meetup
$ cd december-2018-meetup

2. Hook up the database

For this application we’re going to use SQLite. All that’s required to run SQLite locally is a blank file sitting in the database folder.

$ touch database/database.sqlite

Now that we’ve created the raw database file, edit the .env file use sqlite. Delete the other database connection info and replace it:

DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

The .env file is not checked into version control and holds database connection info and API keys.

3. Create a database model, table and controller

--

--

Connor Leech
Employbl

Girl Dad x 2. Cofounder @Employbl. Software Engineer @CommentSold.