Welcome! This Starter Kit helps you quickly launch a Symfony-based REST API project with JWT authentication, user registration, role-based access, and protected routes.
Perfect if you want to skip setup and get straight to building your app.
- ✅ JWT login and token authentication
- ✅ User registration with password hashing
- ✅ Protected routes (authenticated access)
- ✅ Role-based access control (
ROLE_USER,ROLE_ADMIN, etc.) - ✅ Auto-generated API documentation (Swagger via NelmioApiDocBundle)
- ✅ Clean, modular code (Controllers, Services, DTOs)
- ✅ Dev-friendly setup (MakerBundle included)
the client delete the token since the jwt is stateless.
localStorage.removeItem("jwt_token");To keep your project secure, these steps are mandatory after downloading the kit.
The kit includes default development keys. Do not use them in production.
🎯 Run the following command:
php bin/console lexik:jwt:generate-keypairYour new keys will be saved in config/jwt/ and will replace the default ones.
Edit the .env file and update:
JWT_PASSPHRASE=REPLACE_ME
Replace REPLACE_ME with the passphrase you used when generating your key.
The /api/debug/create-user endpoint is intended for development use only.
Options:
- Delete it
- Restrict it based on APP_ENV != prod
- Protect it with a temporary secret/token
Open config/packages/nelmio_cors.yaml and make sure you restrict allowed domains:
allow_origin: ['https://your-domain.com']
To protect /api/login from brute-force attacks, add:
# config/packages/rate_limiter.yaml
framework:
rate_limiter:
login:
policy: 'sliding_window'
limit: 5
interval: '1 minute'
Then annotate your login controller:
#[RateLimit(name: 'login')]
- Clone or unzip the project
- Install dependencies:
composer install - Copy .env to .env.local and set up your DB credentials and JWT passphrase
- Generate JWT keys:
php bin/console lexik:jwt:generate-keypair - Run database migrations:
php bin/console doctrine:database:create php bin/console doctrine:migrations:migrate - Start the server:
symfony server:start
/api/doc
Powered by NelmioApiDocBundle
- Symfony 6.x
- LexikJWTAuthenticationBundle
- Doctrine ORM
- Symfony Security, Validator, Serializer
- NelmioApiDocBundle (Swagger) (not done)
- PHPUnit (not done)
Thanks for choosing this Starter Kit and happy coding with Symfony!