Check the Kirby license programmatically?

Hi community,

For a customer of mine, I’m developping a website using Kirby. It’s way to early to publish the website as a whole, but the customer wishes to deploy a part of it asap.

Up to now, I’m deploying to a development server of mine. In order to adhere to the license conditions, there is no free access to that development installation. Rather, even a bare visitor of this website has to login. Without knowing the credentials, no one from the public can use that website, so I guess that would be ok for Kirby.

Now I’m confronted with the need for the following: The (partial) webpage will be deployed to the customer’s final production server. So its perfectly ok to purchase a license for that server. But the development will carry on, and that will not be on the production server. How can I programmatically check whether I’m on the production server (with a license) or on the development server? I need this decision in order to avoid the login procedure for website visitors.

Maybe I could make use of the GET: /api/system mechanism which I found in the docs. But I have no clue how to make that work in the startup procedure. Any suggestions?
Thanks in advance.

You can check the domain where the installation is running. What sort of login procedure are you using?

1 Like

Yes, sure, I could test for the production server name, which only would require another configuration element.

Thank you, your ideas are simple yet powerful.

If you do want to check for an active Kirby license, you can use the following code:

$isActivated = kirby()->system()->license() !== false;

This is the perfect solution I was after. Thank you, @lukasbestle