I have a couple of modules that I have created and will be to consider that I may take action of selling those on Magento Connect marketplace.

Aside from only adding a license docblock and terms/conditions how can I protect my module from people using without paying for a license?

I think there are 2 things i want to cover on this question

  1. What is the correct way to generate license keys and distribute them to customers

  2. How can i do number 1 and make things hassle free for my customers


Ioncube and uglifying are the two ways you shouldn't go, but answer your question.

ioncube plays kind of nice with newest xdebug versions, but is not PHP7 compatible yet.

Both options are (afaik) reversable, you loose comments and variable/method names, but nonetheless you can reverse engineer them and remove afterwards the license.

Beside this I recommend to all my customers HARDLY to not deploy any encoded code to production. We review everything and a lot of modules phoning home, sending order or even customer data somewhere or have a log of bugs and security problems, we can fix (and send patches back to vendor).

As with all DRM fck sht, you punish your paying customers, because your modules are not debuggable, slower and we don't trust you.

  • We protect our Magento extensions with ioncube too. But as a serious vendor we a) have integrated our own logging table with various levels up to full detailed logging and b) give support too. Sure you can reverse ioncubed files, but it's really hard to 'read' after it. And we implemented a license check against our license server. So ioncube isn't that bad choice, as long as you don't need PHP7. This is ioncubes part, that imho already takes too long.
    – Michael
    Jun 18 '16 at 8:08
  • What happens when your license server goes down? I remember a time when a vendor's license check server went down and broke hundreds of sites at once!
    – benmarks
    Jun 18 '16 at 14:47
  • Even worse, what happens when you go bankrupt, the license server goes away and your former customers are f*cked. Jun 19 '16 at 14:40

@Marty Wallace If you're interested in really locking down your module, some people use http://www.ioncube.com/ to encode the Php code...and then you only give people the license once they have paid. Here's an answer on SO discussing the process at a high level: https://stackoverflow.com/a/4595441 .

There's also http://www.zend.com/en/products/zend-guard .

Please note that if you go this route, that there are ill feelings from the community, for the most part, for using an encoder. Ioncube ruins debugging (such as Xdebug) capabilities. I have heard that Zend Guard is kinder and still allows debugging to work (I haven't tried though).

I hope that this helps.

*This was answered during #MageStackDay


One of the ways that you can protect your code is by distributing through Magento Marketplace (full disclose: I'm me). We finally have code-level anti piracy checks built into extension review, and we handle immediately and with great prejudice vendors which pirate code. Given this & assuming that the vast majority of merchants will acquire Magento extensions through Marketplace means that the distribution method itself becomes a great defense against piracy.


Aside from only adding a license docblock and terms/conditions how can I protect my module from people using without paying for a license?

Sad truth is - you can't. Keep in mind that even the biggest publicly listed software vendors in the world are struggling with piracy so consider where you want to spend your efforts.

There are options for encoding php which have been mentioned in the other answers. However all will fail the hassle free step as they require your customer to download a binary and install it as a php extension. Also if someone is determined to get to your code, there are ways.

One reason that I chose not to encrypt my code is that if I put myself into my customer's position I would want to be able to read and work with the code that I bought. Also I am fairly sure that people who are willing to run counterfeit/stolen code would not be buying my extension in the first place. And who knows what other nefarious modifications have been slipped into it, people would be buying/downloading from thieves.

What is the correct way to generate license keys and distribute them to customers

Whatever works for you and causes you the least amount of support requests. I think the most convenient way for customers would be to create a personalised download which already includes the serial number you created for them.

Keep in mind that if you do not encrypt your code any serial number validity check is easily defeated. However I do believe doing serial numbers, even if easily circumvented, does act as a reminder that the code in question is tied against a certain use (domain).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.