This project provides an API to fetch, store, and serve character data from the Rick and Morty series.
- Laravel: The PHP framework used to build the API.
- MySQL: The database management system used to store character, episode, and location data.
- Docker: Used to containerize the application environment.
- Laravel Sail: A lightweight command-line interface for interacting with Laravel's Docker development environment.
- Postman: A collaboration platform for API development. A Postman collection is included in the
docs
directory to demonstrate API endpoints and usage. - PHPUnit: The unit testing framework for PHP. Unit tests are included in the
tests
directory to ensure the reliability of the application.
Installation
< 6F0E /div>- Clone this repository:
git clone https://github.com/user/repository.git
- Copy the .env.example file to .env:
cp .env.example .env
-
Configure the .env file according to your environment.
-
Run Sail's installation command:
./vendor/bin/sail up -d
- Create the database and migrate tables:
./vendor/bin/sail artisan migrate
- To fetch data from the Rick and Morty API and store it in the database, run the following command:
./vendor/bin/sail artisan rickandmorty:getdata
You can access the data by making HTTP requests to the API. For example:
Send a GET request to list all characters:
GET http://localhost/api/characters
Send a GET request to view a specific character:
GET http://localhost/api/characters/{id}
Send a POST request to create a new character:
POST http://localhost/api/characters
Send a PUT request to update a character:
PUT http://localhost/api/characters/{id}
Send a DELETE request to delete a character:
DELETE http://localhost/api/characters/{id}
A Postman collection is available in the docs directory. Import this collection into Postman to explore and interact with the API endpoints.
Unit tests are included in the tests directory. You can run the tests using PHPUnit to ensure the reliability of the application.