Prerequisites
Before you begin, ensure you have the following installed:- PHP 7.1.3 or higher
- Composer
- MySQL or another supported database
- Git
Setup steps
Install dependencies
Install the required PHP packages using Composer:This will install all dependencies including:
- Laravel Framework 5.7
- Firebase PHP-JWT 3.0.0
- Laravel Tinker
Configure environment
Copy the example environment file and generate an application key:Open the
.env file and configure your database connection:Make sure to create the database before running migrations.
Run database migrations
Create the necessary database tables:This will create the
users table and other required tables.Make your first API call
Now that your API is running, let’s make some authenticated requests.Register a new user
Create your first user account by sending a POST request to the register endpoint:The API expects user data to be sent as a JSON string within a
json parameter. The password is hashed using SHA-256.Login and get JWT token
Authenticate with your credentials to receive a JWT token:Make an authenticated request
Use the JWT token to make authenticated API calls. Here’s an example updating user information:All authenticated endpoints require the JWT token in the
Authorization header. Replace the token value with your actual token from the login response.Next steps
Now that you’ve made your first authenticated API call, you can:- Explore the available endpoints in the API Reference
- Learn about category and post management
- Implement image upload functionality
- Integrate the API into your application
The JWT token is validated using the secret key defined in
app/Helpers/JwtAuth.php:13. In production, make sure to use a secure secret key.