Skip to content
For Sellers

License Keys and Domain Activation for Code You Sell

What a software license key system can and cannot do when you sell readable source code, how domain activation works, and how to add a verify-once license check to your installer using a license verification API, with a test plan.

• Nov 17, 2026 • 11 min read
License Keys and Domain Activation for Code You Sell

A software license key system for source code does three jobs: it proves a buyer purchased the product, it records where the product is installed, and it lets your code adjust its behavior to the edition the buyer owns. It does not make readable source code impossible to copy, and trying to make it do that usually hurts honest buyers more than pirates. The approach that works best for most sellers is simple: ask for the key once in the installer, verify it on the server against a license API, bind it to the installation's domain, and then get out of the way.

This guide explains how that works and how to add it to your product. It is part of our broader guide on how to sell your web app or SaaS source code. On AppTrovo, every sale issues a license key automatically, with domain activation and a license verification API, so you do not have to build the licensing server yourself, only the small client-side check in your installer.

If you only want the API reference, go straight to the license integration guide. Read on for the reasoning, the trade-offs and a test plan.

What can a license key actually protect?

When you sell readable source code, a determined person can always remove a license check. Being honest about that helps you design something useful instead of something annoying.

A license key system canA license key system cannot
Confirm a buyer has a valid purchase before installationStop someone from deleting the check in readable code
Record which domains a license is activated onPrevent a buyer from sharing a ZIP file
Tell your code which edition the buyer ownsReplace a clear license agreement
Show whether support and updates are activeGuarantee payment in every case
Give you a clean record when handling support or disputesMake up for a product buyers do not trust

Think of the license key as a receipt with an address on it, not a lock. Most buyers of business software are honest and want to stay on the right side of the license, especially when updates and support depend on it. The key makes the honest path the easy one.

Should you obfuscate or encode your code?

Some sellers try to protect PHP scripts by encoding or obfuscating them. For a source code marketplace, that is usually a mistake:

  • Buyers pay for the source. The reason they choose a self-hosted app is the ability to read, audit and change it. Encoded files remove that value.
  • Encoders add hosting requirements such as special loaders, which cause installation failures and tickets.
  • Obfuscation hides bugs from you too, and makes security review by the buyer impossible.
  • It rarely stops piracy. Pirated copies of encoded products circulate anyway.

Spend the effort on things that make paying worthwhile: updates, support, documentation and features in the Commercial edition. Those are what a pirated copy never gets.

How domain activation works

Domain activation binds a license key to the places where the product is installed. The flow on AppTrovo looks like this:

  1. The buyer purchases the product and receives a unique license key (a UUID).
  2. During installation, your installer sends the key and the installation's domain to the license verification API from the server.
  3. If the key is valid and an activation slot is free, the domain is recorded against the license and the response confirms it.
  4. Running the installer again on the same domain does not use another slot.
  5. If the buyer moves to a new server or domain, they deactivate the old domain from their dashboard and activate the new one. See managing domain activations.

Each license has a limited number of activation slots, and the verify response tells you how many are used (activations_used) and available (activations_limit). That limit lets a buyer run a production site and a staging copy without asking you, while discouraging installs across dozens of unrelated domains. What the license allows legally is defined by the license terms, not by the slot count.

Verify once or phone home?

There are three common strategies for when your code checks the license. The choice matters more than any other licensing decision, because it decides whether licensing can break a buyer's production site.

StrategyHow it worksRisk to buyersRecommendation
Verify once at installThe installer checks the key; the app runs normally afterwardsVery low; a network problem only affects the installerRecommended default
Periodic re-checkA scheduled job verifies the key every day or weekMedium; outages, firewalls or rate limits can trigger false failuresAvoid unless you have a strong reason
Check on every requestEach page load calls the license serverHigh; slows every page and makes your server a single point of failureDo not use

AppTrovo's integration guide recommends verify-once: after the installer succeeds, the product writes an "installed" marker and never calls the API again. A buyer's production app should never stop working because a license server could not be reached during a network problem.

How to add a license check to your installer

The verification API is a single GET request to /api/v1/licenses/verify with the license_key, and optionally your product_slug and the installation domain. Sending the product slug is recommended, because it ensures the key belongs to your product and not to another one. Here is the installer flow in steps:

  1. Ask for the key. Add a license step to your web installer with one field. The buyer should not have to type a product name or edit configuration files; set your product slug in your own config before you package the ZIP.
  2. Verify on the server. Call the API from your backend with a short timeout and SSL verification on. Never verify from browser JavaScript, and never put secrets in client-side code.
  3. Send the domain. Pass the installation host so the activation is recorded against it.
  4. Handle the response. If valid is true, store what you need locally: the edition from license_type, the licensee name, and support dates if your admin area shows them. If it is false, show the failure_reason in plain language and let the buyer try again.
  5. Mark the install complete. Write the installed marker and continue with the database and admin user steps. PHP's version_compare() is also handy later if your admin area compares the installed version with the latest release. From here on, no licensing code runs.

For Laravel products there is a drop-in installer SDK with a ready-made installer controller and a small middleware that only checks for the installed marker. The full parameter list, response fields and failure reasons are in the license verification API article and the integration guide. The API is rate limited (120 requests per minute per IP at the time of writing), which is another reason not to check on every request.

Store the result safely

Treat the license key like any other credential: keep it out of public directories, out of logs and out of the frontend. The OWASP Secrets Management Cheat Sheet has general guidance on handling keys and tokens in applications.

Gate features by edition, not by domain

AppTrovo products come in exactly two editions: a free, feature-limited Community edition (buyers may run it in production, without author support) and a paid Commercial license that unlocks the full feature set. There is no third tier. The verify response tells you which one the buyer has in license_type (community or commercial, plus developer for your own test keys).

  • Gate on license_type, not on the edition object's slug. The Commercial edition's internal slug is a permanent identifier that does not read "commercial", so license_type is the field designed for gating.
  • Store the edition during installation in your settings table and read it locally at runtime.
  • Decide clearly what each edition includes and say it on the listing. Hidden limits that appear after installation feel like a trick.

The response also includes product.retired. If you ever retire a product, existing licenses keep verifying, and your admin area can show a gentle notice that no further updates are planned.

Handle development, staging and moving servers

Licensing that ignores real workflows creates tickets. Plan for these cases:

  • Local development. Buyers install on localhost or a .test domain first. Decide whether your installer counts that as an activation; many sellers skip the domain for local hosts.
  • Staging copies. Activation slots exist so a staging site does not need a second license. Mention this in your docs.
  • Server migrations. Document the steps: deactivate the old domain in the dashboard, move the files, re-run the license step or installer on the new domain.
  • Agencies installing for clients. Explain which domain should be activated and who should hold the key. Point to the license terms for client use.

Test your integration before you submit

You do not own a paid license for your own product, so AppTrovo lets every author generate a free developer test license from the product's edit page. It activates only on local domains such as localhost, 127.0.0.1 or hosts ending in .test or .local, expires after 30 days and can be extended. New authors without a product yet can use a sandbox license to try the flow. Run these scenarios:

ScenarioHow to trigger itExpected result
Valid key, new domainFresh install on localhostInstaller continues and stores the edition
Valid key, same domain againRe-run the installer on the same hostInstaller continues; no extra activation used
No free slotsActivate the maximum number of local domains, then one moreClear message explaining how to deactivate a domain
Invalid keyEnter a random UUIDClear error; the installer stays on the license step
Expired keyUse an expired test keyClear "license has expired" message
Network failureBlock the API host on your machineFriendly error with a retry button, not a blank page

Before packaging, remove any development bypass flags you added while testing, and make sure the API base URL points at production.

Write the license step for humans

The license screen is often the first thing a buyer sees after uploading your files. A few details make it friendly:

  • Tell buyers where to find their key (for AppTrovo buyers, the Licenses section of their dashboard).
  • Accept the key with or without surrounding spaces, and trim it.
  • Translate API failure reasons into next steps: "This key has no free activation slots. Deactivate a domain you no longer use in your dashboard, then try again."
  • Link to your troubleshooting page for license errors. Our guide to documentation that cuts support tickets shows how to write those entries.

Frequently asked questions

Do I need to build my own license server to sell code?

Not on AppTrovo. Every sale issues a license key, buyers manage domain activations from their dashboard, and you verify keys through the license verification API. Your work is a small license step in your installer. If you also sell on your own site, you will need a separate licensing solution for those sales.

Can a license key stop piracy of PHP scripts?

No license check can fully stop someone from editing readable source code. It does confirm purchases, record installations and connect buyers to updates and support. Most piracy is better answered by making the paid product clearly more valuable, through updates, support and Commercial features.

What happens if the license server is down during installation?

With the verify-once pattern, only the installer is affected. Show a friendly error with a retry option and keep the buyer's input. Once installed, the app never depends on the license server, so a later outage cannot affect it.

How does a buyer move their license to a new domain?

They deactivate the old domain from their dashboard, which frees the activation slot, and then run the license step on the new domain. Document this in your installation or migration guide so buyers do not need to contact you.

Should the Community edition require a license key?

Community licenses also have keys, and the verify response reports them as community. Using the same installer flow for both editions keeps your code simpler and lets you enable Commercial features when a buyer later purchases the Commercial license and enters the new key.