After PHP code is encoded using a third-party encoder (IonCube, Zend Guard). What about using reflection with the encoder? Doesn't that give a lot of the code away?
It's more nuanced than that. The public code (function names, global variables, etc) that are designed to be interacted will all be public.
As far as using reflection, it's not that hard to disable reflection for an internal function/class (which is what they would do). This wouldn't necessarily error, but it could return garbage. Since the encoders have access to C, assume they can do anything they want.
Well, not anything. At some point, the code still needs to be executed. And to be executed, it needs to have an opcode array. The opcode array lists every operation in every function.
And since reversing from opcodes into PHP code isn't difficult, encoders are basically little more than obfuscators once run in a valid environment.
The value-add that an encoder can do is encrypting the opcode so that you can't run it on a non-licensed server. But once you can run the code you can do whatever you want with it.
Code encoded with older versions is bound to be cracked at some point.
No. Code with all versions can be cracked. All it needs is the ability to be executed.
My solution was to encode the code AFTER having it obfuscated (custom written obfuscator). Everything is minified into a single file and obfuscated. Anything beyond the native PHP functions/variables is gibberish.
That's exactly what the encoder does anyway. Except for the public code (designed to be interacted with or extended by developers), the rest is just pointers. All naming information is lost. So obfuscating it yourself isn't necessary.
So, how would you rate the safety of the code? Is obfuscation worth it?
The question you haven't answered is who you are trying to protect the code from.
Are you concerned about someone using your code unlicensed? If so, no encoder can protect you. Because all the user needs to do is dump the opcodes and they can have the code (without variable names, but they don't need that to run it). It's not as trivial as that, but it's 100% doable.
Are you concerned about someone modifying your code? Well, they can get the code anyway... So...
Are you concerned about someone looking into the code to find things? Like security vulnerabilities? Well, they can do that anyway. And trying to obfuscate it is not going to help.
Are you concerned about the average user making modifications? Then encoding will prevent that.
If not, are there any alternatives?
The alternative is licensing. You don't need to hide the code to protect it. License it under a restrictive commercial license. And use the legal system to go after anyone who steals or breaks the license. This is about the only effective way of protecting software.
What would you consider an optimal solution?
Not encoding, that much I can tell you :-)