Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kitchh's avatar

SAAS App: How to enable/disable features per tenant/customer?

Q1: I am trying to visualize how to build integrate features in such a way that they are available only for specific customers (only if they are enabled for them). E.g.: We have a Invoicing feature in our product. We want to enable it only for specific customers in the backend itself so that they cannot access any of these routes/apis.

Similarly, extending this concept to a granular level - Say, we have invoicing feature for specific customers. Now, we want to enable invoice print / invoice email sub-features (facilities?) only to sub-set of these specific customers.

How do we do this? Extend permissions/gates/policies to work at tenant level? Is there any reference to such functionality which I can go through?

Q2. Extending my thoughts further, Assume we want to modify functionality - like, we always email invoices after generation for the existing customers. For this new customer, we want to display the PDF in the browser after creation & not email it out. How to we extend (in OOPS terms) or make the code/controller code work differently for different customers? Looking at some options to override the existing code specific to some specific customer requirements (like how you possibly do it in drupal? this is one of those setups where you have such facilities if I recollect right - have separate site specific code in addition to base code.. )

Any thoughts and explanations on this?

PS: Obviously we are looking at hosting a single instance of the code base here for all customers, but having customization for specific customers. I understand that our framework structure is not intended for such functionality (or at least that is how I understand it), but I still want to think in this direction and get feedback.

Thanks.

0 likes
2 replies
bobbybouwmann's avatar

Q1: Normally you would use "feature flags". This can be a boolean that is true or false per tenant. You have two options for this. Either storing this in the database or in some config file. With feature flags, you can develop features that are not public right away. So you can easily test for one client or a few clients.

You can also solve this on authorization level, but if a feature if complex because different roles are involved, you need to do a lot more checks to get this working. With the feature flag, you just test against one thing.

Also, you can cache the result of the feature flag until the next deployment. This way it's really fast in calculation this :)

Q2: You can do this in a few ways. Either have this logic in your controller and based on a config or feature flag return the pdf or send the email. The other solution is using something like a decision tree of an adapter. You basically will have service class that should decide based on the customer which other action to trigger to make this work. Your controller should not be responsible for this, but a different class.

2 likes
Snapey's avatar

I'm using this package in a couple of places https://github.com/akaunting/setting

It can be extended to scope settings to specific users (or tenants). You could put a simple admin panel on it, allowing you to decide what features are turned on for which tenants.

2 likes

Please or to participate in this conversation.