Protecting your PHP source-code

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Protecting your PHP source-code

Post by patrikG »

For those of us who use PHP commercially and sell their applications, this is very nice indeed.
http://pecl.php.net/package/bcompiler wrote:bcompiler enables you to encode your scripts in phpbytecode, enabling you to protect the source code.
bcompiler could be used in the following situations

- to create a exe file of a PHP-GTK application (in conjunction with other software)
- to create closed source libraries
- to provide clients with time expired software (prior to payment)
- to deliver close source applications
- for use on embedded systems, where disk space is a priority.
http://pecl.php.net/package/bcompiler
User avatar
llanitedave
Forum Commoner
Posts: 78
Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.

Post by llanitedave »

This gives me a chance to ask for some clarifications about the GPL or about the PHP license, which I must admit to not having a real good understanding of.
Does the GPL'd language allow you to create proprietary (closed source) works using that language? Does the PHP license differ from the GPL in that respect, or is that an interpretation of open-source licenses in general?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

llanitedave wrote:Does the GPL'd language allow you to create proprietary (closed source) works using that language?
No. If you modify a php app distributed under GPL, the licence also applies to your modified version. This means developments are fed back into the community.

BSD does not impose this restriction.
User avatar
llanitedave
Forum Commoner
Posts: 78
Joined: Thu Jan 15, 2004 11:24 am
Location: Las Vegas, NV.

Post by llanitedave »

So, any application developed using PHP and the GPL'd version of mySQL must itself be GPL'd?

That's what I had thought, but I wasn't sure.
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

Don't mean to be contrary but I'll add one caveat to McGruff.

He's right in that if "modify a php app distributed under GPL, the licence also applies to your modified version." The key word there is app. You can't take someone elses source code for a PHP app that is distributed via GPL and put it into a non-GPL project. For example, you can't take a database abstraction set of classes that is GPL'd and incorporate it into your non-GPL'd database abstraction commercial product.

You can howver use the PHP language to develop an application that is not GPL'd. You can develop a PHP application that is intended to work with MySQL and have that application be non-GPL'd as well. You cannot distribute the MySQL source or binaries with that app in that case. You cannot distribute the PHP source or binaries either in that case.

Easy example - Linux is GPL. I can write a commercial program to run on Linux. I cannot distribute Linux as a part of that commercial program.

My suggestion if you need PHP + db is:

1) Write in PHP without fear, just require that the end user have PHP etc. properly installed and running.
2) Drop MySQL. It is a pig anyways.
3) Use SQLite instead. You can distibute the SQLite code with/inside your app, as it's not GPL. Plus in PHP 5 it will be enabled by default.
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

One more thing. bcompiler gives the illusion of security. It is one step more than simple obfuscation techniques, but not a very big one. Decompiling PHP byte code is easy enough for those who know what to do.

I think it's a great idea if that's what you need, I just don't like the way it is described. They toss around words like "compiled" and "bytecode" to give the impression to prospective (and less knowledgeable in PHP nuts and bolts) users that it is something analogous to compiled C/C++. It is not.

My nit is with the implications of their description. Implications that I feel intentionally overstate and potentially mislead.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

People that can reverse-engineer bytecode to sourcecode are probably smart enought to write the php script themselves....
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

Rotten people are often lazy people. ;)
Post Reply