There are all sorts of things you can do to make it more difficult for people to use unlicensed versions of your application, but I'm not aware of any solution that works 100% of the time.
Obfuscation
You can use obfuscate your code using something like ZendGuard or Source Guardian, but that will likely annoy legitimate customers who need to see your source and it still won't be 100% effective.
Call Home
You could bury a "call home" somewhere in your code that will let you know where your application is installed. If you think someone has an unlicensed version you would then have the ability to reach out to them and let them know they need the licensed version.
This code could be removed just like the licensing check, but unlike the licensing check it does not need to be removed in order for your application to work without a license.
In practice, I don't think the issue you are trying to address is that big of a problem. The subset of people who don't want to pay for your software, but will be persuaded to pay by your licensing solution is pretty small.
I would focus my time on improving my application rather than trying to deter freeloaders, possibly at the expense of legitimate customers.
Consider offering incentives to legitimate customers that unlicensed users would not have access to such as support and updates.