Download the PHP package dwivedianuj9118/laravel-api-starter without Composer
On this page you can find all versions of the php package dwivedianuj9118/laravel-api-starter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dwivedianuj9118/laravel-api-starter
More information about dwivedianuj9118/laravel-api-starter
Files in dwivedianuj9118/laravel-api-starter
Package laravel-api-starter
Short Description A complete API Starter Kit for Laravel 11+ designed to accelerate backend development. This package provides a clean and scalable API architecture with authentication, request validation, standardized API responses, error handling, and best practices. Perfect for SaaS platforms, mobile apps, admin panels, and high-performance REST APIs built with Laravel.
License MIT
Homepage https://anujdwivedi.in
Informations about the package laravel-api-starter
README.md
Laravel API Starter ๐
- ๐ Website: https://anujdwivedi.in
- ๐ Company: https://papayacoders.com
- ๐ฆ Packagist: https://packagist.org/packages/dwivedianuj9118/laravel-api-starter
- ๐ GitHub: https://github.com/dwivedianuj9118/laravel-api-starter
A production-ready API starter package for Laravel 11+ designed to help you bootstrap APIs instantly without reinventing the wheel. This package is opinionated but highly configurable, tailored for real-world backend applications.
โจ Features
- โ Dual Auth Support: JWT Authentication (for mobile/external) & Sanctum SPA Authentication.
- โ Toggleable Auth: Enable or disable JWT/Sanctum via config.
- โ Standardized Responses: Uniform JSON structure for success and error states.
- โ
API Versioning: Pre-configured versioning (defaults to
/api/v1). - โ Auto-Documentation: Swagger/OpenAPI integration out of the box.
- โ Robust Error Handling: Global API exception handling (No more HTML errors in your API!).
- โ
Health Monitoring: Dedicated
/healthendpoint for uptime checks. - โ Performance: Built-in rate limiting and JSON-only enforcement.
-
โ Laravel 11 Ready: Fully compatible with the latest Laravel structures.
๐ฆ Requirements
- PHP: 8.2+
- Laravel: 11+
๐ฅ Installation
Install the package via Composer:
Configuration
Publish the configuration file to customize the behavior:
Environment Variables (.env)
Add or modify these variables to control your API behavior:
JWT Guard
You must define a JWT guard in config/auth.php.
Ensure provider exists
๐งฏ Global API Exception Handling
The package automatically ensures JSON-only API exception responses.
If you want to customize exception rendering further, you may optionally integrate
ApiExceptionHandler into your global exception flow.
๐ bootstrap/app.php (Laravel 11+)
This ensures: No HTML error pages Consistent API error responses Validation & auth errors normalized
๐ App\Providers\AppServiceProvider.php
๐ Preparing the Authentication Model (JWT & Sanctum)
This package supports JWT authentication and Sanctum SPA authentication.
Your authentication model (usually User) must be configured correctly.
JWT & Sanctum Model Setup (Required)
To enable JWT and Sanctum authentication, update your auth model (usually User) as follows:
- Implement
JWTSubject - Use
HasApiTokenstrait - Add the two JWT methods
If you are using JWT authentication, you must also define a JWTSubject interface in your model. And if you are using Sanctum authentication, you must also define a HasApiTokens trait in your model.
If you are using JWT and want to use middleware, you can use the auth:jwt middleware. And if you are using Sanctum, you can use the auth:sanctum middleware.
Default:
๐ Authentication
1. JWT Authentication
Ideal for mobile apps and external clients.
- Register:
POST /api/v1/auth/register - Login:
POST /api/v1/auth/login - Refresh:
POST /api/v1/auth/refresh - Logout:
POST /api/v1/auth/logout
To disable, set `API_ENABLE_JWT=false`
2. Sanctum SPA Authentication
Optimized for first-party web applications.
- Login:
POST /api/v1/spa/login - Logout:
POST /api/v1/spa/logout
To disable, set `API_ENABLE_SANCTUM=false`
Custom Auth Model
You can define which model is used for authentication (e.g., for an Admin panel):
Note: Your model must extend
Illuminate\Foundation\Auth\Userand use theHasApiTokenstrait.
๐ API Response Format
All responses are returned as structured JSON.
Success Response
Error Response
Swagger Setup (Optional)
Install Swagger:
Edit the generated file:
๐ config/l5-swagger.php
Update the annotations paths:
๐ REQUIRED: Sanctum Security Scheme (Swagger)
Make sure this exists in config/l5-swagger.php
Generate documentation:
Access Swagger UI at:
/api/documentation
๐ Features in Detail
Health Check
Monitor your application status easily.
- Endpoint:
GET /api/v1/health
Rate Limiting
Prevent abuse with built-in throttling (per IP).
- Default: 60 requests/min.
- Customization: Update
API_RATE_LIMITin your.env.
๐งช Testing
Run the package test suite:
๐ Roadmap
- [ ] OAuth / Social Login support
- [ ] Multi-guard API configurations
- [ ] API Key-based authentication
- [ ] Webhook signature verification support
๐ License
The MIT License (MIT). Please see License File for more information.
ยฉ 2026 Dwivedianuj9118
All versions of laravel-api-starter with dependencies
laravel/framework Version ^11.0 || ^12.0
laravel/sanctum Version ^4.0
tymon/jwt-auth Version ^2.0
darkaonline/l5-swagger Version ^9.0