A Laravel 12 API boilerplate with file uploads using cloudinary, authentication using sanctum and socialite, email verification, forgot password, rate limiter, and exception handling.
- 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
This API requires the following:
- PHP >= 8.2
- Composer
- Laravel Framework >= 12.x
- Cloudinary
- MySQL
- Git
- Clone the repository
git clone https://github.com/codebykenth/laravel-boilerplate-v1.git
cd laravel-boilerplate-v1- Install Dependencies
composer install- Set Up Environment File
cp .env.example .env- Generate Application Key
php artisan key:generate- Run Database Migrations (Optional)
php artisan migrate- Serve the Application
php artisan serve- Update mail, database, cloudinary, facebook, and google config in .env file
-
Go to Facebook for Developers.
-
Log in and create a new app (or select an existing one).
-
Go to Settings > Basic to find your App ID and App Secret.
- FACEBOOK_CLIENT_ID = App ID
- FACEBOOK_CLIENT_SECRET = App Secret
- 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)
-
Go to the Google Cloud Console.
-
Create a new project (or select an existing one).
-
Go to APIs & Services > Credentials.
-
Click Create Credentials > OAuth client ID.
-
Choose Web application and set your Authorized redirect URIs (e.g., http://localhost:8000/auth/google/callback).
-
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)
-
Go to Cloudinary and sign up (free tier available).
-
Go to Dashboard > API Keys > Generate New API Key
-
Copy and paste it in your .env
- Enable 2-Step Verification and App Passwords in Gmail
- Go to your Google Account Security settings.
- Enable 2-Step Verification.
- Go to Google App Password.
- Generate an app password (give it a name like "Laravel").
- Copy the generated password.
- Update your .env file
- Replace the placeholders in your .env
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