A modern Laravel 11 boilerplate with extended utilities and command tools for faster and cleaner backend development. Includes built-in JWT, Mailer, Validator, Service base classes, and artisan generators.
-
Laravel 11 base with extended architecture.
-
Additional libraries:
firebase/php-jwtβ For secure JWT handling.phpmailer/phpmailerβ For direct email sending via SMTP.
| Library | CDN | Description |
|---|---|---|
| Tailwind CSS | @tailwindcss/browser@4 |
Utility-first CSS framework |
| DaisyUI | @5 |
Prebuilt UI components for Tailwind |
| Remix Icon | @4.5.0 |
Lightweight and modern icon pack |
| Tom Select | @2.4.3 |
Dropdown and autocomplete control |
| DataTables | dt-2.3.4 |
Interactive tables with search, export, and pagination |
| Google Fonts β Quicksand | Main application font |
| Library | CDN | Description |
|---|---|---|
| jQuery | 3.7.1 |
DOM manipulation & event handling |
| Axios | Latest CDN | HTTP client for API calls |
| Tom Select JS | @2.4.3 |
Select dropdown controller |
| PDFMake | 0.2.7 |
Client-side PDF generation |
| DataTables JS Bundle | Matched with CSS version | Export and responsive features |
| File | Description |
|---|---|
alert.js |
Custom SweetAlert-like modal using <dialog> |
axios.js |
Axios wrapper with interceptor for unified error handling |
common.js |
Global helpers (form handling, formatting, tables, selects, etc.) |
prompt.js |
Custom prompt modal for user input |
state.js |
Lightweight reactive state handler |
common.js (main) |
Entry point for UI initialization, flash system, theme toggle, etc. |
- Default font: Quicksand
- Minimalist custom scrollbar
- Dark/light theme toggle with
localStorage.themeMode - Right-click disabled and history caching prevention
- Loading overlay and image preview system
Generate a new service file under app/Services.
php artisan make:service UserServiceGenerate a new validator file under app/Http/Validators.
php artisan make:validator UserValidatorPath: app/Http/Controllers/Controller.php
Provides two helper methods:
json()β unified JSON API response.view()β render view with optional headers and status code.
Path: app/Http/Middleware/Cache.php
Automatically disables client-side caching for every request:
Cache-Control: no-cache, no-store, must-revalidatePath: app/Http/Validators/Base.php
Simplifies request validation and alias mapping with a consistent structure:
[
'status' => true|false,
'data' => [...],
'error' => [...]
]Path: app/Services/Base.php
Provides a unified layer for:
- Safe database transactions (
handler()) - File management (upload, delete, multiple uploads)
- Database error parsing
- Unified JSON response builder
Includes helpers like:
uploadSingleFile()uploadMultipleFiles()uploadUrlFile()deleteFile()/deleteMultipleFiles()upsertHasOne()for relational updates
Path: app/Utils/Flash.php
Lightweight session flash helper:
flash('success', 'User created!');
flash_get('success'); // => "User created!"
flash_clear(); // clear all flash dataPath: app/Utils/JWT.php
Wrapper for firebase/php-jwt with .env auto-configuration.
Methods:
JWT::generate($payload, $ttl = 0)JWT::verify($token)JWT::decode($token)JWT::encode($data)
Supported .env keys:
JWT_ALGO=HS256
JWT_SECRET=your-secret-key
JWT_TTL=3600Path: app/Utils/Mailer.php
Wrapper for PHPMailer with Laravel-style configuration.
Config file: config/phpmailer.php
return [
'debug' => env('MAILER_DEBUG', false),
'credentials' => [
'host' => env('MAILER_HOST', ''),
'auth' => env('MAILER_AUTH', true),
'user' => env('MAILER_USERNAME', ''),
'pass' => env('MAILER_PASSWORD', ''),
'secure' => env('MAILER_SECURE', true),
],
];Supported .env keys:
MAILER_DEBUG=false
MAILER_HOST=
MAILER_AUTH=true
MAILER_NAME=
MAILER_USERNAME=
MAILER_PASSWORD=
MAILER_SECURE=trueUsage:
use App\Utils\Mailer;
Mailer::send([
'to' => 'user@example.com',
'subject' => 'Welcome!',
'body' => '<b>Hello User</b>',
]);Path: app/Providers/AppServiceProvider.php
Automatically initializes JWT and Mailer on boot:
JWT::init();
Mailer::init(config('phpmailer'));bootstrap/app.php registers:
- Web & API middleware groups
- Global Cache middleware
- Custom command registrations for
ServiceMakerandValidatorMaker
git clone https://github.com/yourname/laravel-11-boilerplate.git
cd laravel-11-boilerplate
composer install
cp .env.example .env
php artisan key:generate
php artisan migrateThen serve your app:
php artisan serve- PHP >= 8.2
- Composer >= 2.x
- Laravel 11.x
- MySQL or SQLite (for default migrations)
- OpenSSL (for JWT)
namespace App\Http\Controllers;
use App\Services\UserService;
class UserController extends Controller
{
public function index(UserService $service)
{
$response = $service->getAllUsers();
return $this->json($response);
}
}namespace App\Services;
class UserService extends Base
{
public function getAllUsers()
{
return $this->handler(function () {
$users = \App\Models\User::all();
return $this->json(true, 200, 'Success', $users);
});
}
}This project is open-sourced software licensed under the MIT license.