This repository contains a REST API built with Laravel, designed to manage a collection of stores and products. The API allows users to perform CRUD operations on stores and products, including creating, reading, updating, and deleting data.
You can find me on:
- Docker Desktop
- Composer v2.0 or higher
Clone repository:
git clone https://github.com/jcortesa/laravel-store-rest-api
cd laravel-store-rest-api
Create a .env
file by copying the example file:
cp .env.example .env
Install dependencies and start the application using Laravel Sail:
composer install
./vendor/bin/sail up -d
In browser, navigate to http://localhost
to access the API.
The API provides the following endpoints:
POST /api/stores
: Create a new store. Pass a collection of products in the request body to associate them with the store.GET /api/stores
: Retrieve a list of all stores.GET /api/stores/{id}
: Retrieve a specific store by ID.PUT /api/stores/{id}
: Update an existing store by ID.DELETE /api/stores/{id}
: Delete a store by ID.PUT /api/stores/{storeId}/products/{productId}/sell
: Sell a product from a store. This endpoint will update the stock of the product and return the updated product details.
See specification on docs/api.yaml
.
Test it also with docs/api.http
using HTTP Client by JetBrains.
To run the tests, use the following command:
./vendor/bin/sail artisan test
Making use of PHPStan to analyze the code quality, run the following command:
./vendor/bin/sail bin phpstan analyze
This project is licensed under the MIT License. See the LICENSE file for details