Direction: Implement an [or a set of] API that can do Browse, Read, Edit, Add, Delete (BREAD) operations against a sql database table.
Used:
- Lumen
- JWT for authentication
Setup:
- Clone Repository
$ git clone https://github.com/pjsalita/bread.git
- Change directory and install dependencies
$ cd bread $ composer install
- Create .env file and update APP_KEY to random string 32 characters string
$ cp .env.example .env
- Create database.sqlite file under database folder
$ touch database/database.sqlite
- Run migrations and seeders
$ php artisan migrate --seed
- Generate jwt secret
$ php artisan jwt:secret
- Serve
$ php -S localhost:8000 -t public
Note: Make sure php-sqlite extension is installed/enabled.
Seeded user(to skip registration for testing):
- Username: sample
- Password: password
Endpoints:
- http://localhost:8000/api/v1/register (POST) (params: name, email, username, password, password_confirmation)
- http://localhost:8000/api/v1/login (POST) (params: username, password)
- http://localhost:8000/api/v1/customers?page=1... (GET) (can have per_page, sort, order, and page)
- http://localhost:8000/api/v1/customers/{id} (GET, PATCH, DELETE) (PATCH params: firstname, lastname, date_of_birth, is_active)
- http://localhost:8000/api/v1/customers (PUT)