Skip to content

NetLicensing Setup

Alexey Averikhin edited this page Dec 4, 2026 · 3 revisions

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.

1. What you get

  • 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.

2. Try it without an account

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 error

Then 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.features of config/protection.php (Reports included, Projects up to 5). A whole number is a quota, -1 unlimited; true or false turns a feature on or off.
  • /member/example opens. With NETLICENSING_FAKE_STATE=expired it sends you to the page that offers a plan.
  • Remove REPORTS from fake.features to see a feature refused (step 9).

Test mode refuses to run in production. When you like what you see, connect your own product.

3. Create a vendor account

Sign up at NetLicensing, then work in the console.

4. Product

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.licensee in config/protection.php.

Copy the product number:

NETLICENSING_PRODUCT_NUMBER=MYAPP

5. Subscription module

Your 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-MEMBERSHIP

This module opens the member area (members.view in config/permissions.php) and is the plan on Home.

6. Pricing Table module

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-PLANS

The 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.

7. API key

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:doctor check the product and module, the key needs a role that may read them (for example Admin). Or list the plans by hand under plans in config/protection.php and keep the Licensee key.
NETLICENSING_APIKEY=your-key

Never commit a real key. .env is not in git; keep it that way.

8. Connect the application

NETLICENSING_ENABLED=true
NETLICENSING_DRIVER=netlicensing
php artisan config:clear
php artisan app:doctor --licensing

app:doctor names every missing or rejected setting and the step of this guide that fixes it. The admin dashboard lists the same.

9. Open an area by plan

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):

  1. A permission in config/permissions.php, under list, listed under areas if it is an area:

    'reports.view' => 'permissions.reports_view',
  2. 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'],
    ],
  3. 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');
  4. 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.

  5. Tick reports.view on 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.

10. Buy a plan as a user

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.

11. Going live

  • 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_URL with your public address.
  • Run php artisan app:doctor --licensing on the server.

12. Troubleshooting

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).

Clone this wiki locally