A RESTful API built with PHP and MySQL that allows users to manage their to-do list. It supports pagination and filtering by status. This API uses php-jwt for JWT authentication, phpdotenv for loads environment variables, phpunit for unit testing, and guzzle for PHP HTTP client. Inspired by roadmap.sh
Make sure you have installed:
- PHP: Latest version, to run the API server and scripts.
- MySQL: For storing and managing the todo list data.
To start using the Todo List Tracker API, you need to -
-
Clone the repository.
git clone https://github.com/krisnaajiep/php-todo-list-api.git
-
Install dependencies.
composer install
-
Configure
.env
file.cp .env.example .env
-
Generate JWT Secret.
php index.php jwt:secret
-
Run the Apache web server and MySQL Server.
-
Access the endpoints with the base URL.
This API uses Bearer Token for authentication. You can generate an access token by registering a new user or login.
You must include an access token in each request to the API with the Authorization request header.
If an API key is missing, malformed, or invalid, you will receive an HTTP 401 Unauthorized response code.
API access rate limits apply at a per-API key basis in unit time. The limit is 60 requests per minute. Also, depending on your plan, you may have usage limits. If you exceed either limit, your request will return an HTTP 429 Too Many Requests status code.
Each API response returns the following set of headers to help you identify your use status:
Header | Description |
---|---|
X-RateLimit-Limit |
The maximum number of requests that the consumer is permitted to make per minute. |
X-RateLimit-Remaining |
The number of requests remaining in the current rate limit window. |
X-RateLimit-Reset |
The time at which the current rate limit window resets in UTC epoch seconds. |
The following status codes are returned by the API depending on the success or failure of the request.
Status Code | Description |
---|---|
200 OK | The request was processed successfully. |
201 Created | The new resource was created successfully. |
401 Unauthorized | Authentication is required or the access token is invalid. |
403 Forbidden | Access to the requested resource is forbidden. |
404 Not Found | The requested resource was not found. |
409 Conflict | Indicates a conflict between the request and the current state of a resource on a web server |
422 Unprocessable Content | The server understands the request, but cannot process it due to a validation error |
429 Too Many Request | The client has sent too many requests in a given amount of time (rate limiting). |
500 Internal Server Error | An unexpected server error occurred. |
In case you have questions or need further assistance, you can refer to the following resources: