Hi friend!
I would compile my file php under under Linux.
Have you got an idea of this? (free solution...)

Thanks a lot
[Gnomix]

Recommended Answers

All 31 Replies

PHP code doesn't really get compiled as you would compile a C++ program, for example. Rather the code is executed by your web server client when someone accesses the php page. I don't know the technical term for what it's called ... but you need a web server such as Apache (comes with most linux distributions otherwise www.apache.org) that can server your php scripts to clients connecting to it.

well but there is "zend encoder" to compile php page... but it's have a hight price... do you know a free solution? or a good obfuscator

thanks

www.php.net

Go to downloads... downlaod what you need... absolutely free and open source.

PHP is compiled at run time. The Zend Optimiser merely cleans up the code to make it compile faster... but it is always compiled at run time; ie, when a user accesses the webpage.

yeah as said before you dont need a compiler to say, for php. all you do is name it .php file and put it in your web directory and access it with a browser and the server with parse the code and show the output. but you will need php on your system and the module compiled into apache to do this so go to php.net as said and download it so you can install it to make it work :) good luck and have fun

A free alternative to Zend is Turck mmCache. According to their website:

Turck MMCache is a free open source PHP accelerator, optimizer, encoder and dynamic content cache for PHP. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated. Also it uses some optimizations to speed up execution of PHP scripts. Turck MMCache typically reduces server load and increases the speed of your PHP code by 1-10 times.

To be perfectly honest, Daniweb has always used mmCache :)

www.php.net

Go to downloads... downlaod what you need... absolutely free and open source.

PHP is compiled at run time. The Zend Optimiser merely cleans up the code to make it compile faster... but it is always compiled at run time; ie, when a user accesses the webpage.

My question isn't how compile php from his tar.gz (download from www.php.net) but compile a my script in php so others people can't view my code in my .php page, also if open .php with a text editor

you dont have to worry about that cause the min your access a php script from a browser it will parse the information and all the person viewing the site could see is html. like if you go and look at a php page using any browser and then go view source code all you will see is the html output of the php program :) i hope this helps if not im not quite sure what you are looking for

You dont' understand my question...
I have create a software web in php and I commercialize it.. so I would protect my php file!!

I don't actually think this is possible.

And everyone, PHP is never compiled. It is a scripting language; therefore it is interpreted (at runtime). A web language like ASP.NET is fully compiled (at the page's first view or at design time into a managed dll file).

What he is trying to do is protect his code when he distributes it as a commercial application.
You can use Turck mmCache but it appears that it may be able to be decrypted:

Since version 2.3.10, Turck MMCache contains a PHP encoder and loader. You can encode PHP scripts using encoder.php in order to distribute them without sources. Encoded files can be run on any site which runs PHP with Turck MMCache 2.3.10 or above. The sources of encoded scripts can't be restored because they are stored in a compiled form and the encoded version doesn't contain the source. Of course, some internals of the scripts can be restored with different reverse engineering tools (disassemblers, debuggers, etc), but it is not trivial.

I would suggest http://www.ioncube.com ($199) to protect your code if Zend is too expensive for you. They also have an online version which is A LOT CHEAPER. http://www.ioncube.com/online_encoder.php
It costs like $.50 per file.

OK - Turck mmCache is software which compiles php code to lessen the server load (by as much as 500 to 1000%) when the code is interpreted at run time. There is software such as that that cyberwisdom mentioned which can be used to encode php files so that the php code itself can be distributed. Note that when you put php files on the web, and someone loads a .php page, there is absolutely no way for them to determine or get the php code that was used to build the page.

It is possible to compile PHP code into a standalone application. I've seen a media-database that was written in PHP, but all I had to to is run an EXE file.

I googled a bit and this is what I found:
--quote from website http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler --
Compile Stand Alone Applications

PCC allows you to compile your PHP source into stand alone applications. No interpreter is required. Your source is compiled into an optimized machine executable program. The program is distributable with or without the source code and cannot be decompiled back into it's original PHP source. Distribution (or sale) of your compiled programs is royalty free.

It is possible to compile PHP code into a standalone application. I've seen a media-database that was written in PHP, but all I had to to is run an EXE file.

I googled a bit and this is what I found:
--quote from website http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler --
Compile Stand Alone Applications

PCC allows you to compile your PHP source into stand alone applications. No interpreter is required. Your source is compiled into an optimized machine executable program. The program is distributable with or without the source code and cannot be decompiled back into it's original PHP source. Distribution (or sale) of your compiled programs is royalty free.

Yes, I've heard of this, but it doesn't make sense to start an application from scratch using PHP. I guess if you already had plenty of code, APIs and what not that you wanted to reuse, you could utilize PHP. However, It doesn't make sense to me creating a server or a desktop application using a language that was designed for the web.

Yes, I've heard of this, but it doesn't make sense to start an application from scratch using PHP. I guess if you already had plenty of code, APIs and what not that you wanted to reuse, you could utilize PHP. However, It doesn't make sense to me creating a server or a desktop application using a language that was designed for the web.

I agree that it doesn't make that much sence, but the question was if it was possible to compile PHP.
The only reason I can think of why someone would compile/build an executable is because PHP has huge support of databases and other stuff, as well as lots of cross-platform things. But again, you could use C(++) or Java, as well as other languages to build cross-platform things.

I agree that it doesn't make that much sence, but the question was if it was possible to compile PHP.

Yup, I know. I was only throwing in my two cents on how I thought it didn't make much sense. I know that almost nothing is impossible because I'm always surprised that someone, somewhere, has done it.

Great reason to use PHP to develop a stand-alone exe:
You've got a bunch of php programmers, and you want to either speed up the execution of your scripts, or you just need to make an exe for some reason, and you know php, so why not use that and do it faster, rather than re-invent the wheel?

Also, php is a forgiving and easy language to develop with, especially due to the loose typing and memory management features, as well as the nearly seamless integration with raw PL output and data-layer elements. You can do more faster with less effort.

In an extreme situation, where it was an emergency and I had plenty of PHP libraries in store, did not know another language as well, and performance was not an issue, then yes, I would use PHP. Otherwise I would go with C/VC++.

I may answer why do I use PHP and why would I love to compile it... :p

I am analyzing lots of data from lots of anemometers all around the world. Basicaly, the data comes in, as TXT files, mostly daily in 10 minutes statistics. That means 144 files a day.

Most of the data structure are the same but of course different people has different ideas on achiving the data. But, for my analyz I need a database to keep them all in a standart format. That speeds up my analyz time. So, I need a tool, which is flexiable, to dump this data into the DB as I wish.

I had two options first time I started to do that, either a good C++ code which can be compiled and works fast, OR a scripting tool that can communicate with MySQL server easily. I was familier with PHP so I have used it. According to my tests my very first C++ code was dumping a file in 6 seconds. But, PHP was dumping in 13 seconds. What the hell all I miss is 7 seconds for each file.

PHP is easy to edit. I do not need to worry about memory allocation and I have good ready functions to edit strings. And when I show to PHP where is the MySQL server, it kills ... ;)

And all I need is PHP and a little switch in php.ini.

So, if anyone can compile PHP on Win32 system FOR FREE, I am buying a round of beer. :cheesy:

I may answer why do I use PHP and why would I love to compile it... :p

I am analyzing lots of data from lots of anemometers all around the world. Basicaly, the data comes in, as TXT files, mostly daily in 10 minutes statistics. That means 144 files a day.

Most of the data structure are the same but of course different people has different ideas on achiving the data. But, for my analyz I need a database to keep them all in a standart format. That speeds up my analyz time. So, I need a tool, which is flexiable, to dump this data into the DB as I wish.

I had two options first time I started to do that, either a good C++ code which can be compiled and works fast, OR a scripting tool that can communicate with MySQL server easily. I was familier with PHP so I have used it. According to my tests my very first C++ code was dumping a file in 6 seconds. But, PHP was dumping in 13 seconds. What the hell all I miss is 7 seconds for each file.

PHP is easy to edit. I do not need to worry about memory allocation and I have good ready functions to edit strings. And when I show to PHP where is the MySQL server, it kills ... ;)

And all I need is PHP and a little switch in php.ini.

So, if anyone can compile PHP on Win32 system FOR FREE, I am buying a round of beer. :cheesy:

I may be able to help you on that one...I'm going to buy a RoadSend license in something like less than a month, so I will be able to compile whatever you want to compile FOR WIN32

cscgal: how is it possible to reduce something "by as much as 500 to 1000%"?

leelee: now it will take a negative amount of time to execute. Twilight zone, here we come :mrgreen:

Actually, I think she meant increase the speed by that much.

http://www.priadoblender.com/

Where's the beer???? :eek:

I use this to make executable files from PHP files. I mean, you run the code in something such as DOS, but at least it works. I use it when I don't have a PHP server in hand.

There are good reasons to encode php scripts. These may include: protecting intellectual property for distribution, licensing, protecting scripts from being manipulated or changed, and increasing performance.

Check out these packages:
Source Guardian
Php Cipher
PHP Shield
Nu-Coder
Byte Run
SourceCop

Hi friend!
I would compile my file php under under Linux.
Have you got an idea of this? (free solution...)

Thanks a lot
[Gnomix]

I wonder how did you dig out that old thread. The question was asked 3 years ago. :)

The question may have been asked 3 years ago, but the information is still in the search engines. It is never a bad time to add additional information.

:) cool !

Sure you can

To make PHP a Windows or Linux binary to execute offline, you can use roadsend, then double click the resulting exe (in the windows case):), you can also embed a tiny web server in that exe (ships with roadsend)! or compile it as console application

To make your code not readable by humans and still run on your LAMP setup, you can use the encode feature of the free eaccelerator (encoder has been depreciated i think so you can only use an OLDER version)

A lower priced nice solution is ioncube, it is very good

Also need to mention that in IONCUBE and eaccelerator's case, reverse compiling your code is not impossible... it has to live in a stack in memory as opcode to run, and someone with plenty of experience and time (Experience and free time don't usually come together) can decompile it, she will not end up with your exact code, variables will have different names like (variable1 and variable2) but in general, if you don't write a hit operating system no one invests that much time cracking your code, it might be easier to rewrite it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.