This project is a RESTful API built using Laravel. It demonstrates product management with CRUD operations, pagination, caching, factories, and seeders.
The project is designed to help understand backend API development and performance optimization using caching.
- Product CRUD API
- Pagination support
- API caching for faster responses
- Database seeders
- Model factories
- RESTful API design
- JSON responses
- Laravel
- PHP
- MySQL
- REST API
- Laravel Cache
- Laravel Pagination
Clone the repository
git clone https://github.com/yourusername/laravel-product-api.git
Navigate to project folder
cd laravel-product-api
Install dependencies
composer install
Copy environment file
cp .env.example .env
Generate application key
php artisan key:generate
Configure database in .env file
Run migrations
php artisan migrate
Seed database
php artisan db:seed
Run the server
php artisan serve
API will run at
Get paginated products
GET /api/products?page=1
Create product
POST /api/products
Update product
PUT /api/products/{id}
Delete product
DELETE /api/products/{id}
Products are returned in pages using Laravel pagination.
Example request
/api/products?page=2
Each page returns 10 products.
Product list responses are cached using Laravel Cache.
Cache key example
products_page_1
This improves API performance by reducing database queries.
Cache is cleared whenever a product is created, updated, or deleted.
The project includes seeders and factories to generate sample data.
Run
php artisan db:seed
This will generate 100 sample products.
This project demonstrates:
- REST API development
- Pagination implementation
- API caching strategy
- Laravel factories and seeders
- Backend performance optimization
Backend practice project built for learning Laravel API development.