Skip to content

A Laravel 12 API boilerplate with file uploads using cloudinary, authentication using sanctum and socialite, email verification, forgot password, rate limiter, and exception handling.

Notifications You must be signed in to change notification settings

codebykenth/laravel-boilerplate-v1

Repository files navigation

Laravel API Boilerplate

A Laravel 12 API boilerplate with file uploads using cloudinary, authentication using sanctum and socialite, email verification, forgot password, rate limiter, and exception handling.

Table of Contents

Features

  • Media Single and multiple file upload/s using Cloudinary
  • Laravel Queue for file upload
  • Authentication using Laravel Sanctum and Socialite
  • Verify Email and Forgot Password
  • Pagination
  • MySQL for database
  • API Rate Limiter
  • Exception Handling

Requirements

This API requires the following:

  • PHP >= 8.2
  • Composer
  • Laravel Framework >= 12.x
  • Cloudinary
  • MySQL
  • Git

Installation

  1. Clone the repository
git clone https://github.com/codebykenth/laravel-boilerplate-v1.git
cd laravel-boilerplate-v1
  1. Install Dependencies
composer install
  1. Set Up Environment File
cp .env.example .env
  1. Generate Application Key
php artisan key:generate
  1. Run Database Migrations (Optional)
php artisan migrate
  1. Serve the Application
php artisan serve

Configuration

  • Update mail, database, cloudinary, facebook, and google config in .env file

Setup Facebook

  1. Go to Facebook for Developers.

  2. Log in and create a new app (or select an existing one).

  3. Go to Settings > Basic to find your App ID and App Secret.

  • FACEBOOK_CLIENT_ID = App ID
  • FACEBOOK_CLIENT_SECRET = App Secret
  1. Set your redirect URI in Facebook Login > Settings (e.g., http://localhost:8000/auth/facebook/callback for local).
  • FACEBOOK_REDIRECT = your callback URL (must match what you set in Facebook)

Setup Google

  1. Go to the Google Cloud Console.

  2. Create a new project (or select an existing one).

  3. Go to APIs & Services > Credentials.

  4. Click Create Credentials > OAuth client ID.

  5. Choose Web application and set your Authorized redirect URIs (e.g., http://localhost:8000/auth/google/callback).

  6. After creation, you'll see:

  • GOOGLE_CLIENT_ID = Client ID
  • GOOGLE_CLIENT_SECRET = Client Secret
  • GOOGLE_REDIRECT = your callback URL (must match what you set in Google)

Setup Cloudinary

  1. Go to Cloudinary and sign up (free tier available).

  2. Go to Dashboard > API Keys > Generate New API Key

  3. Copy and paste it in your .env

Setup Mail

  1. Enable 2-Step Verification and App Passwords in Gmail
  1. Update your .env file
  • Replace the placeholders in your .env

API Endpoints

Auth Routes
🟧 POST http://127.0.0.1:8000/api/login → Login user
🟧 POST http://127.0.0.1:8000/api/logout → Logout user
🟩 GET http://127.0.0.1:8000/api/auth/{provider} → Get the link for login
🟩 GET http://127.0.0.1:8000/api/auth/{provider}/callback → Handle the social login

🟧 POST http://127.0.0.1:8000/api/email/verification-notification → Send email verification
🟩 GET http://127.0.0.1:8000/api/email/verify/{id}/{hash} → Verify email
🟧 POST http://127.0.0.1:8000/api/password/email → Send password reset link
🟧 POST http://127.0.0.1:8000/api/password/reset → Reset password
🟩 GET http://127.0.0.1:8000/api/password/reset → View reset password page

User Routes
🟩 GET http://127.0.0.1:8000/api/users → Get all users
🟩 GET http://127.0.0.1:8000/api/users/{id} → Get user by ID
🟧 POST http://127.0.0.1:8000/api/users → Create/Register user
🟪 PUT http://127.0.0.1:8000/api/users/{id} → Update user
🟧 POST http://127.0.0.1:8000/api/users/profile-picture → Update profile picture
🟥 DELETE http://127.0.0.1:8000/api/users/{id} → Delete user

Test Routes (For multiple file uploads)
🟩 GET http://127.0.0.1:8000/api/tests → Get all tests
🟩 GET http://127.0.0.1:8000/api/tests/{id} → Get test by ID
🟧 POST http://127.0.0.1:8000/api/tests → Create/Register test
🟧 POST http://127.0.0.1:8000/api/tests/{id}/tests-images → Update test
🟥 DELETE http://127.0.0.1:8000/api/tests/{id} → Delete test

About

A Laravel 12 API boilerplate with file uploads using cloudinary, authentication using sanctum and socialite, email verification, forgot password, rate limiter, and exception handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages