what is the best way to create a premium plugin while also protecting your code

I am a premium plugin developer for about two years and only had the thought of protecting my code for a glance of a second for two reasons.

First, as a freelance developer and client of other premium products, I was and am always suspicious about encrypted parts in the code and rather remove such a plugin and ask for a refund if possible.

Second, as stated by Samuel Elh, I too believe in support and updates to give value to customers.

Depending on the platform, they probably have tutorials on how to handle license keys. I am using Easy Digital Downloads’ Software Licensing and they provided this info and sample codes.

It can always happen that someone copies/steals or optimizes your code, but copying an image and additional value (like helpful support) is rather hard.

You should also be aware that making your product depend on a call to an external database adds the question of performance to the table. Anything “calling home” is a huge risk on both ends.