One of the most reliable methods for protecting scripts from the study and modification is obfuscation.
Obfuscation (from Latin obfuscare, "shade, darken") - entanglement of the program code, that is, bringing the source text to a form that preserves the functionality of the program, but complicates the analysis, understanding of the algorithms and modification.
The first stage of deobfuscation is the formatting of the script's text, hyphenation, alignment of the code that is easy to read with "ladder". For this I use two tools. The company WaterProof Software has developed a small (less than 100 kilobytes) free program for formatting PHP code phpCodeBeautifier . To download it from offsite requires free registration, so here's for the convenience of a direct link to the download. The program is console, the command line parameters can be viewed in the instructions from the archive. For fans of the windows there is a GUI-version, though the older one, but it is quite possible to put a console file from the latest version.
When you format large scripts, the browser can display a message that the script is frozen, and will prompt you to stop it. You do not need to do this, it takes more time to process.
If obfuscation did not replace the names of variables, then after formatting the code, deobfuscation can be considered complete. In any case, the script is already much more readable and understandable
If the names of variables and functions are corrupted, then go to the second part of deobfuscation. Here, unfortunately, there are no ready-made tools, or at least I have not met them. If someone wants to take up the writing of such a tool free of charge, then I can provide a detailed technical assignment. While it is necessary to be limited to theoretical calculations.
This article describes only the general principles of deobfuscation, for each case it will be necessary to think and apply an individual approach. But usually, it is not necessary to completely de-buffize to perform an algorithm cracking or parsing an individual function.