PHP specific:
There are PHP code encryption and obfuscation tools such as Zend Guard, IonCube , Source Guardian and several others that increase the barrier against others easily copying, re-using and/modifying your PHP code.
But there is no absolute protection to be achieved there.
The generally accepted simplification is:
Whatever safeguards and encryption you built into your software, they will not protect you from a determined adversary that has full control over the hardware where your software is running.
That why you normally also have additional protection and something engineers often overlook:
Code is Intellectual Property and there is a complete legislative industry surrounding protection methods for IP. Think in terms of contracts, copyright, patents etc. etc.