# how to license a laravel application
Licensing a Laravel app involves creating a system to validate keys, often using an external server/API for security, checking against domains/users, restricting features, and handling expirations, with options like using dedicated packages (e.g., [laravel-ready/license-server](https://packagist.org/packages/laravel-ready/license-server), [shumonpal/laravel-licence-client](https://packagist.org/packages/shumonpal/laravel-licence-client)) for server-side or client-side checks, or building custom logic via middleware to verify keys at setup or on each request for features and access.
Key Components of Licensing
- **License Server:** A central system (often another Laravel app) to generate, store, and validate license keys, managing domains/users. - **Client Application:** Your main Laravel app that checks its license status via the server/API. - **License Keys:** Unique identifiers (UUIDs are common) tied to a product, user, domain, or time. - **[Middleware](https://www.google.com/search?q=Middleware&oq=how+to+license+a+laravel+application+&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORifBTIHCAEQIRigATIHCAIQIRigATIHCAMQIRifBTIHCAQQIRifBTIHCAUQIRifBTIHCAYQIRifBTIHCAcQIRifBTIHCAgQIRifBTIHCAkQIRifBTIHCAoQIRifBTIHCAsQIRiPAtIBCTE2NDc5ajBqN6gCFLACAfEF-eTJQaLm_6k&client=ms-android-oppo-rev1&sourceid=chrome-mobile&ie=UTF-8&mstk=AUtExfDczmOiRKmck-3A5kJC4FJfUtYC6V3OBBZ2qwALyvFeFYh9W70b33g0leiDO_mwzin6uL0mqe5LfWbr5j2ha426RreXgCM8eGLhgCJ8-MbP84awPAGsc-f6KvJrMGIea1IgY6UVn4wC_z2jMD54i9RnQfS6UqBehw8KPB0zr9G8-JI&csui=3&ved=2ahUKEwjS-Ib3hL2RAxXJUGwGHYRELDUQgK4QegQIAxAE):** To enforce checks on routes or specific features.
This video provides a basic introduction to creating a login and registration system in Laravel:
![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/v2XJiAET2oSXSjDv-embedded-image-k6mkwu58.png)
58s
[
Net Ninja
YouTube • 6 Jan 2025
](https://www.youtube.com/watch?v=3JBmbQsR0ag&t=351)
Implementation Steps
1. **Choose Your Approach:** - **SaaS/API:** Best for control; clients use credentials to access your service. - **Self-Hosted with Key:** Use packages or custom code for validation within the app.
This video demonstrates how to implement a login and registration system in Laravel from scratch:
![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/MG1dKBHUd7Z97Ul5-embedded-image-usp4kk1j.jpeg)
55s
[
Laravel
YouTube • 30 Apr 2025
](https://www.youtube.com/watch?v=QtKZxNNPT_U&t=133)
2. **Set Up Your License Server (if applicable):** - Use packages like `laravel-ready/license-server` to manage licenses (add 2. **Up Your License Server (if applicable):** - Use packages like `laravel-ready/license-server` to manage licenses (add to domain/user, set expiration, etc.). - The server handles key generation and verification logic.
This video explains how to use the Laravel Breeze package to add a login and registration system:
![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/PwmdeKQjuh1DghX3-embedded-image-wg5befkt.jpeg)
1m
[
Yelo Code
YouTube • 29 Aug 2023
](https://www.youtube.com/watch?v=3aZAE3Mw5y4&t=405)
3. **Implement Client-Side Verification:** - Install a client package (e.g., `shumonpal/laravel-licence-client`) or build custom logic. - Publish configuration and point to your license API endpoint in `config/app-licence.php`. - Use the package's middleware (e.g., `LicencedVirifiedMiddleware`) in your `Kernel.php` to protect routes.
This video shows how to create a registration form in Laravel:
![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/x4cQaV4h4Ffmx1Q0-embedded-image-gaj9adlq.png)
59s
[
Igor Babko
YouTube • 22 Jul 2025
](https://www.youtube.com/watch?v=kRXkll4H8yY&t=275)
4. **Create Activation/Validation Flow:** - **During Setup:** Prompt user for key; verify against server to enable features/create database tables. - **On Request:** Use middleware to check license on every request, caching results for performance.
This video provides an overview of the authentication system in Laravel:
![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/JaVkkB6LhR37FTnS-embedded-image-omd5sdxn.png)
58s
[
Net Ninja
YouTube • 6 Jan 2025
](https://www.youtube.com/watch?v=3JBmbQsR0ag&t=351)
5. **Handle License Expiry:** - Restrict features, disable updates, show pop-ups, or revert to basic functionality.
Best Practices
- **External API:** Keeps your core logic secure and allows for updates/revocation. - **Caching:** Cache license status to avoid constant server calls. - **Legal:** Consult a lawyer for complex licensing agreements.
This video demonstrates how to create a custom login and registration system from scratch:
![Related video thumbnail](https://articles.ravapps.com/uploads/images/gallery/2025-12/BqyLYion2tILHFJM-embedded-image-4jzblaxt.jpeg)
1m
[
Codes Easy
YouTube • 5 Dec 2022
](https://www.youtube.com/watch?v=jmTJBGxn8vA&t=1325)
---
Licensing a Laravel app involves creating a system to validate usage, often using an **external license server** (like `laravel-ready/license-server`) or **API calls**, to check keys against domains/users, restrict features, and manage expirations, typically with middleware for real-time checks and caching for performance. You'll need to build logic for key generation, activation/deactivation, and enforce license rules (e.g., per domain, per user, feature gating) within your application's core logic and routes, ensuring secure communication with your license service.
Here's a breakdown of steps and concepts:
**1. Choose Your Licensing Model**
- **SaaS API:** Best for cloud-hosted apps; users pay for API access, restricting direct code access. - **Self-Hosted with Key:** For distributed apps (like CodeCanyon); users get a key, and your app validates it. This is where packages shine.
This video explains how to implement a license verification system for your Laravel application:
1m
[
Philo Hermans
YouTube • 19 Jul 2021
](https://www.youtube.com/watch?v=om2NZMEdv-w&t=106)
**2. Implement Server-Side (License Management)**
- **Use a Package:** Packages like `{Link: laravel-ready/license-server https://packagist.org/packages/laravel-ready/license-server}` provide a central system for managing licenses (keys, domains, users, expiry). - **Create Your Own:** Build a separate Laravel app with an API to manage licenses if you prefer full control. - **Key Generation:** Generate unique, secure license keys (UUIDs are good). - **Licensing Logic:** Define rules (e.g., `addLicense($product, 'domain.com', $userId, $days, $isLifetime)`).
**3. Implement Client-Side (Your Laravel App)**
- **[Client Package](https://www.google.com/search?q=Client+Package&mstk=AUtExfCofILjoOYm5NFQHgpg_IOBcR9YX2wwBObwNUTRc4T02tTlv67vD4eR8WWJi8kP4LMau1JPaEtRpLrSXZetRytgoKgcDue8oIdzWpxfiCo-Zp3jax1pshvVe_8eIwLJUvBvNTf48QoXN-WDiEWCKZT0-npdUWr3u9nw0rec8cNr_04&csui=3&ved=2ahUKEwjEodm8mb2RAxWhe2wGHYXxK1AQgK4QegQICRAB):** Use a connector package (e.g., [shumonpal/laravel-licence-client](https://www.google.com/search?q=shumonpal%2Flaravel-licence-client&mstk=AUtExfCofILjoOYm5NFQHgpg_IOBcR9YX2wwBObwNUTRc4T02tTlv67vD4eR8WWJi8kP4LMau1JPaEtRpLrSXZetRytgoKgcDue8oIdzWpxfiCo-Zp3jax1pshvVe_8eIwLJUvBvNTf48QoXN-WDiEWCKZT0-npdUWr3u9nw0rec8cNr_04&csui=3&ved=2ahUKEwjEodm8mb2RAxWhe2wGHYXxK1AQgK4QegQICRAC) or create your own) to talk to the server. - **[Configuration](https://www.google.com/search?q=Configuration&mstk=AUtExfCofILjoOYm5NFQHgpg_IOBcR9YX2wwBObwNUTRc4T02tTlv67vD4eR8WWJi8kP4LMau1JPaEtRpLrSXZetRytgoKgcDue8oIdzWpxfiCo-Zp3jax1pshvVe_8eIwLJUvBvNTf48QoXN-WDiEWCKZT0-npdUWr3u9nw0rec8cNr_04&csui=3&ved=2ahUKEwjEodm8mb2RAxWhe2wGHYXxK1AQgK4QegQICRAE):** Set your license API URL in the client app's config. - **Middleware:** Apply a middleware to routes (e.g., `LicencedVirifiedMiddleware`) to check the license on every request or key pages. - **Activation/Deactivation:** Logic to handle key activation (maybe on first run) and deactivation. - **[Feature Restriction](https://www.google.com/search?q=Feature+Restriction&mstk=AUtExfCofILjoOYm5NFQHgpg_IOBcR9YX2wwBObwNUTRc4T02tTlv67vD4eR8WWJi8kP4LMau1JPaEtRpLrSXZetRytgoKgcDue8oIdzWpxfiCo-Zp3jax1pshvVe_8eIwLJUvBvNTf48QoXN-WDiEWCKZT0-npdUWr3u9nw0rec8cNr_04&csui=3&ved=2ahUKEwjEodm8mb2RAxWhe2wGHYXxK1AQgK4QegQICRAI):** Restrict features (e.g., basic vs. premium) based on license type or expiry.
This video demonstrates how to set up authentication in Laravel:
58s
[
Yelo Code
YouTube • 29 Aug 2023
](https://www.youtube.com/watch?v=3aZAE3Mw5y4&t=258)
**4. Key Strategies**
- **Check on Request:** Use middleware to intercept requests and verify the license against your server. - **Cache Results:** Cache license checks (e.g., for 5 mins) to avoid hitting the server on *every* request. - **Expiration Handling:** Send reminders and restrict access to basic features or disable usage after a grace period.
**Example Flow (Self-Hosted)**
1. User buys your app. 2. You generate a key and activate it on your license server for their domain/user. 3. User installs the app. 4. On first load, the app calls your API with the key. 5. API verifies key/domain. 6. App uses middleware to check key validity for subsequent requests.
**Essential Tip:** For commercial distribution, consult a lawyer to draft proper licensing terms (e.g., MIT for Laravel, but your own for your product).