Repository navigation
NetLicensing Setup
Your application already knows who a user is (sign-in) and what they may do (roles and permissions). Labs64 NetLicensing adds an optional third step: what they have paid for. A role grants a permission; a plan entitles the user to use it. Access needs both.
This guide takes you from nothing to plans that your users buy and that open parts of your application: about 30 minutes, with no code to write until step 9.
Two licensing models are a good start:
| Model | What a plan gives | Use it for |
|---|---|---|
| Subscription | Access for a period: 30 days, a year | A member area: paid or not |
| Pricing Table | Features (on or off) and quotas (numbers) per plan | Free, Pro and Business plans that open different areas |
You can use one, or both side by side.
Console steps checked against the NetLicensing console in December 2026. Names of buttons may change; the sections stay.
- Home and the account page show each user their plan, its end date and, with a Pricing Table, what it includes.
- A Buy or Extend button takes the user to the NetLicensing Shop and back.
- Areas open only to users whose role grants them and whose plan includes them. A refusal names the missing feature ("This area needs a plan that includes Reports"), highlights it on the plan card, offers Upgrade to a plan with Reports and a way back to Home.
- Administrators see who has a valid plan under Membership and Permissions, and why each user may or may not open something on the user's page.
- Administrators always pass (
protection.except_roles), so test with a normal user.
Licensing is off in a new installation. Turn it on in test mode: answers come from config/protection.php, with no network and no account.
NETLICENSING_ENABLED=true
NETLICENSING_DRIVER=fake
NETLICENSING_FAKE_STATE=valid # valid, invalid, expired or errorThen php artisan config:clear and sign in as demo.laravel@local.local (password demo):
-
Home shows the plan ("Sample plan") and what it includes: the features in
fake.featuresofconfig/protection.php(Reports included, Projects up to 5). A whole number is a quota,-1unlimited;trueorfalseturns a feature on or off. -
/member/exampleopens. WithNETLICENSING_FAKE_STATE=expiredit sends you to the page that offers a plan. - Remove
REPORTSfromfake.featuresto see a feature refused (step 9).
Test mode refuses to run in production. When you like what you see, connect your own product.
Sign up at NetLicensing, then work in the console.
Products → Add product.
- Name: your application's name. Customers see it in the shop.
-
Number: keep the one suggested or type your own, for example
MYAPP. -
Licensee auto-create: switch it on. Every user becomes a NetLicensing customer (a licensee) the first time they are checked, with their email address as number and their name. You can change both under
defaults.licenseeinconfig/protection.php.
Copy the product number:
NETLICENSING_PRODUCT_NUMBER=MYAPPYour product → Product modules → Add module.
- Licensing model: Subscription.
-
Number: for example
MYAPP-MEMBERSHIP. - Optional: Grace period, so that a user who renews a little late keeps access meanwhile.
Add one license template (a plan) per period, type TIMEVOLUME:
| Name | Time volume | Price |
|---|---|---|
| Monthly | 30 days | 9 EUR |
| Yearly | 365 days | 90 EUR |
| Trial | 7 days | 0, Automatic on |
- Automatic: every new customer gets it once: a free trial.
- Hidden: kept out of the shop.
Purchased time adds up: a user who buys a year with 10 days left has 375 days.
NETLICENSING_PRODUCT_MODULE_NUMBER=MYAPP-MEMBERSHIPThis module opens the member area (members.view in config/permissions.php) and is the plan on Home.
Optional: use it when plans differ by what they include, not only by time.
Your product → Product modules → Add module.
- Licensing model: Pricing Table.
-
Number: for example
MYAPP-PLANS. - SKUs: the features and quotas plans can carry. Two to start:
| Number | Type | Meaning |
|---|---|---|
REPORTS |
Feature | The reports area |
PROJECTS |
Quantity | How many projects a user may have |
Add one plan per column of your pricing table:
| Plan | Price | Billing | REPORTS | PROJECTS | Other |
|---|---|---|---|---|---|
| Free | 0 | false | 1 | Auto-assignment on | |
| Pro | 19 EUR | Recurring, month | true | 10 | |
| Business | 49 EUR | Recurring, month | true | -1 (unlimited) |
For each plan, set the Action URL to the NetLicensing Shop, so that the plan's button sells it.
NETLICENSING_PRICING_MODULE_NUMBER=MYAPP-PLANSThe SKU numbers are what your code names in step 9. Users see them made readable (REPORTS as "Reports", API_CALLS as "Api calls"); to choose the wording, add for example "features.API_CALLS": "API calls" to lang/en.json.
Settings → API keys → Add.
- Role Licensee is enough to check licences and to open the shop. Use it in production.
- To let the membership page list your plans from NetLicensing, and
app:doctorcheck the product and module, the key needs a role that may read them (for example Admin). Or list the plans by hand underplansinconfig/protection.phpand keep the Licensee key.
NETLICENSING_APIKEY=your-keyNever commit a real key. .env is not in git; keep it that way.
NETLICENSING_ENABLED=true
NETLICENSING_DRIVER=netlicensingphp artisan config:clear
php artisan app:doctor --licensingapp:doctor names every missing or rejected setting and the step of this guide that fixes it. The admin dashboard lists the same.
The member area is already wired to the Subscription module. To open an area only for plans that include a feature, take a reports area as the example (the add-licensed-feature skill and /member/example show the whole pattern):
-
A permission in
config/permissions.php, underlist, listed underareasif it is an area:'reports.view' => 'permissions.reports_view',
-
The entitlement, in the same file: the config key of the module, then the feature.
'entitlements' => [ 'members.view' => 'protection.membership.product_module_number', 'reports.view' => ['protection.pricing.product_module_number', 'REPORTS'], ],
-
The route asks for the permission (
can:) and the feature (protection:{module},{failed route},{feature}):Route::get('reports', [ReportController::class, 'index']) ->middleware([ 'auth', 'can:reports.view', 'protection:'.config('protection.pricing.product_module_number').',protection.membership.failed,REPORTS', ]) ->name('reports');
-
Part of a page, or a limit in your code:
@if(auth()->user()->hasAccess(config('protection.pricing.product_module_number'), 'REPORTS')) ... @endif
$limit = protection_validate($user)->quota(config('protection.pricing.product_module_number'), 'PROJECTS'); // -1: unlimited
The application shows quotas; what counts against them is yours to decide.
-
Tick
reports.viewon the roles that should have it, under Roles.
Now a user needs both: a role that grants Reports, and a plan that includes it. The user's page in the admin area says which one is missing.
Sign in as a user who isn't an administrator, open Membership and press Buy. The shop shows your plans; after paying, it returns to the application, which forgets the stored answer and asks NetLicensing again. The plan and its features appear on Home, and the area opens.
On your own machine the shop returns through localtest.me, because NetLicensing refuses return addresses with localhost. If your router blocks that name, add 127.0.0.1 localtest.me to /etc/hosts.
NetLicensing's answer is kept until its time to live expires; administrators can repeat a check under Membership.
- Set up payments for your account in the NetLicensing console.
- In production
.env:NETLICENSING_DRIVER=netlicensing(test mode refuses to run there), your key with the Licensee role,APP_URLwith your public address. - Run
php artisan app:doctor --licensingon the server.
Access stays blocked whenever the licence check fails; that is on purpose. php artisan app:doctor --licensing names most problems.
| Message | Check |
|---|---|
Missing parameter "apiKey" |
NETLICENSING_APIKEY in .env, then php artisan config:clear (or config:cache again) |
Unsupported response status code 401 |
The key: copy it again from Settings → API keys |
Unsupported response status code 403 |
The role of the key may not do this (step 7). Creating a shop link also refuses a return address with localhost or an IP address (step 10) |
Unsupported response status code 0 |
The server can't reach NetLicensing: network, DNS, proxy or firewall |
| The shop's return link opens an error page on your machine | Your router blocks localtest.me: add 127.0.0.1 localtest.me to /etc/hosts
|
| A feature is refused although the plan includes it | The SKU number in entitlements and the route must match the console exactly, including case |
| Everyone gets in | Administrators are never checked: test with a normal user. Older copies of app/Http/Middleware/Protection.php let requests through when NetLicensing failed; update it |
Older installations may use settings starting with LABS64_NETLICENSING_; rename them to NETLICENSING_. The shared demo product that .env.example used to carry is no longer documented and may stop answering: create your own (steps 3 to 7).
Laravel Boilerplate
Project home | Laravel documentation | Labs64 NetLicensing | NetLicensing API