This project implements a RESTful API using Laravel, which provides and receives information from a MySQL database. The API is secure and uses JWT authentication to authenticate user requests.
Before you begin, make sure you have installed the following:
- PHP >= 8.3
- Composer
- MySQL
- Clone the repository:
git clone git@github.com:lvmorales1/laravel-APIRESTful.git
cd laravel-APIRESTful
- Install Composer dependencies:
composer install
- Create a
.env
file in the project root and copy the contents from the.env.example
file into it:
cp .env.example .env
Configure the necessary environment variables in the .env file, including the database and JWT settings.
- Generate an application key:
php artisan key:generate
- Run the database migrations:
php artisan migrate
- Start the development server:
php artisan serve
The API will be accessible at http://localhost:8000.
The API uses JWT (JSON Web Token) authentication. To authenticate a request, include the JWT token in the Authorization: Bearer token
header.
- URL:
/api/items
- Method: GET
- Query Parameters: None
- Authentication: Yes, JWT token required
- URL:
/api/items/{id}
- Method: GET
- URL Parameters:
{id}
- Item ID - Authentication: Yes, JWT token required
curl -X GET http://localhost:8000/api/items \
-H "Authorization: Bearer your-jwt-token"
curl -X GET http://localhost:8000/api/items/1 \
-H "Authorization: Bearer your-jwt-token"
The API is documented using Swagger UI. To access the interactive API documentation, start the server and visit:
http://localhost:8000/api/documentation
To run the automated tests, use the following command:
php artisan test
This project is licensed under the MIT License. See the LICENSE
file for more information.