This is a Laravel-based application that interacts with the Swagger PetStore API. It allows users to perform CRUD (Create, Read, Update, Delete) operations on pets using a simple interface.
- Add new pets
- Retrieve a list of pets
- Edit pet details
- Delete pets
- Flash messages for success and error notifications
- Simple UI with pagination and search functionality
git clone https://github.com/dev76bitpl/petstore.git
cd petstore-laravelMake sure you have Composer installed.
composer installDuplicate the .env.example file and rename it to .env:
cp .env.example .envThen, update the necessary environment variables in .env:
PETSTORE_API_BASE_URL=https://petstore.swagger.io/v2/
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:your_generated_key
APP_DEBUG=true
APP_URL=http://localhost
php artisan key:generatephp artisan serveYour application should now be running at http://127.0.0.1:8000/.
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan serveThis application communicates with the Swagger PetStore API to manage pets. The main API endpoints used are:
POST /pet- Add a new petGET /pet/findByStatus?status=available- Get a list of available petsGET /pet/{id}- Get a pet by IDPUT /pet- Update pet informationDELETE /pet/{id}- Delete a pet
- API requests are handled using the GuzzleHTTP client.
- The service layer (
PetService.php) manages API communication. - Error handling and logging are implemented for debugging.
- Simple UI for managing pets
- Flash messages for success and error notifications
- Pagination support
- Search functionality
- "Show My Pets" vs "Show All Pets" filtering
Navigate to /pets/create, fill out the form, and submit.
The /pets page displays a list of pets with pagination.
Click the "Edit" button next to a pet to modify its details.
Click the "Delete" button next to a pet to remove it.
- If an API request fails, a flash message will be displayed.
- Laravel's logging system (
storage/logs/laravel.log) records errors for debugging. - Ensure Laravel's log's section is set correctly in
.env:LOG_CHANNEL=daily LOG_MAX_FILES=30 LOG_LEVEL=debug LOG_FORMAT=line LOG_RESPONSE=true LOG_REQUEST=true LOG_QUERY=true LOG_QUERY_THRESHOLD=0 LOG_STACK=single LOG_DEPRECATIONS_CHANNEL=null
Make sure SQLite or MySQL is installed and enabled in php.ini.
- The PetStore API may clear its database periodically.
- Consider persisting data locally.
- Ensure Laravel's session driver is set correctly in
.env:SESSION_DRIVER=file
- Implement authentication
- Store pet data locally instead of relying on the external API
- Improve UI styling
This project is open-source and available under the MIT License.
Developed by Robert Luczynski. Feel free to reach out with any questions or contributions!