A robust starter project using Laravel 12
for rapid, modern API development.
Clean structure, best practices, authentication, and a suite of developer tools out of the box.
# 1. Clone the repository
$ git clone <your-repo-url>
$ cd laravel-boilerplate
# 2. Install dependencies
$ composer install
$ npm install && npm run build
# 3. Copy .env and configure
$ cp .env.example .env
# 4. Generate app key
$ php artisan key:generate
# 5. Run migrations and seeders
$ php artisan migrate --seed
# 6. Start the server
$ php artisan serve
- Authentication (Laravel Sanctum)
- Role & Permission Management (Spatie Laravel Permission)
- Media/File Management (Plank Mediable)
- API Documentation (L5-Swagger)
- Request Monitoring (Laravel Telescope)
- Log Management (Log Viewer)
- Queue Monitoring (Laravel Horizon)
- Performance Monitoring (Laravel Pulse)
- Code Style (Laravel Pint)
- Static Analysis (Larastan/PHPStan)
- Universal Developer Panel Protection (Littlegatekeeper)
In addition to standard Laravel variables, set these in your
.env
:
FRONT_WEBSITE_URL
— The URL of your frontend applicationMASTER_PASSWORD
— Master password for privileged/admin operationsMASTER_OTP
— Master OTP code for bypassing OTP verificationDEVELOPER_USERNAME
/DEVELOPER_PASSWORD
— Credentials for the developer panelLOG_DAILY_DAYS
— Days to retain log files takes 30 days defaultTELESCOPE_ENABLED
— Enable/disable Laravel TelescopeCDN_ENABLE
— Enable/disable CDN usage for media URLsCDN_URL
— The base URL of your CDN for media assetsONESIGNAL_APP_ID
/ONESIGNAL_API_KEY
— Your OneSignal App ID and API Key for push notificationsNOTIFICATION_ENABLED
— Enable or disable the notification system (true/false)
site.php
— Site-wide settings (frontend URL, pagination, roles, OTP, user status)media.php
— Media/file upload settings (tags, directories, CDN, types, MIME mappings)aws.php
— AWS credentials/settings for S3 and related services
Localization files are in resources/lang/en/
:
email.php
— Email-related stringsentity.php
— Entity names/messagesmessage.php
— General messagesstatus.php
— Status labels/messagesnotification.php
— Notification titles and descriptions
Each file returns an array of key-value pairs for use with Laravel's __()
and trans()
functions.
- Auth: Register, Login, Logout, Get Profile, Forget Password (OTP), Reset Password
- User: Update Profile, Change Password, Change Status (Admin)
- Country: List countries (with filters)
- Language: List languages
- Master Settings: List and detail endpoints
- Signed URL: Generate signed URLs for file uploads
API documentation is auto-generated and available at
/api/documentation
via Swagger (L5-Swagger).
app/Http/Controllers/Api/
— API controllers (RESTful, thin, service-driven)app/Http/Requests/
— FormRequest classes for validationapp/Http/Resources/
— API resource and collection transformersapp/Services/
— Business logic and service classesapp/Models/
— Eloquent modelsapp/Rules/
— Custom validation rulesapp/Libraries/
— Libraries classes
php artisan telescope:clear
— Clears all entries/data from Laravel Telescopephp artisan pulse:clear
— Clears all entries/data from Laravel Pulse
- MediaRule: Reusable validation for media/image fields (tags, mime types, nullable/required)
- MediaHelper: File naming, extension detection, media attachment/deletion, aggregate type detection
- Image Optimization: Configured via
config/mediable.php
for automatic optimization (JPEG, PNG, GIF, WebP, AVIF)
- All emails use a custom Blade layout:
resources/views/emails/layouts/master.blade.php
- Branded header with logo
- Localized greetings and sign-off
- Centralized content section (
@yield('content')
) - Footer with copyright
-
This boilerplate includes a robust notification system using Laravel's native features.
- Channels Supported: Database, Email, and optional custom channels (e.g., SMS).
- How It Works: Notifications are created as classes in
app/Notifications/
. You can add new notification types by creating additional classes in this directory. - API Integration: Endpoints are available for listing, marking as read/unread, and managing user notifications.
See the
app/Notifications/
directory and related controllers/services for implementation details.
/developer/telescope
— Laravel Telescope/developer/log-viewer
— Log Viewer/developer/pulse
— Laravel Pulse/developer/login
— Login for developer tools- Authentication: Protected by
DEVELOPER_USERNAME
andDEVELOPER_PASSWORD
in.env
- Lint staged PHP files:
npx --no-install lint-staged
- Code style check:
./vendor/bin/pint
- Static analysis:
./vendor/bin/phpstan --memory-limit=2G analyse
- Run tests:
./vendor/bin/phpunit
If you have issues committing, ensure pre-commit hooks are executable:
chmod ug+x .husky/pre-commit
- Pint: Run
./vendor/bin/pint
to auto-format code. VS Code users can bind Pint toCtrl+S
for instant formatting. - Larastan/PHPStan: Run
./vendor/bin/phpstan analyse
for static analysis.
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
For questions, suggestions, or support, please open an issue or contact the maintainer.