954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Compile PHP

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

Thanks a lot
[Gnomix]

gnomix
Newbie Poster
4 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 

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.

cscgal
The Queen of DaniWeb
Administrator
19,433 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

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

gnomix
Newbie Poster
4 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 

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.

Roberdin
Supreme Evil Overlord
Team Colleague
282 posts since Feb 2003
Reputation Points: 63
Solved Threads: 6
 

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

big_k105
PFO Founder
Team Colleague
357 posts since May 2003
Reputation Points: 36
Solved Threads: 2
 

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 :)

cscgal
The Queen of DaniWeb
Administrator
19,433 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

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

gnomix
Newbie Poster
4 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 

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

big_k105
PFO Founder
Team Colleague
357 posts since May 2003
Reputation Points: 36
Solved Threads: 2
 

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

gnomix
Newbie Poster
4 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 

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).

Tekmaven
Software Architect
Moderator
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
 

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.

cyberwisdom
Newbie Poster
1 post since Jun 2004
Reputation Points: 10
Solved Threads: 0
 

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.

cscgal
The Queen of DaniWeb
Administrator
19,433 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

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.

Patrickske
Newbie Poster
10 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 
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.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 
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.

Patrickske
Newbie Poster
10 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 
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.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

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.

IsaacSchlueter
Newbie Poster
1 post since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

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++.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

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:

TheTurk
Newbie Poster
1 post since May 2005
Reputation Points: 10
Solved Threads: 0
 

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 compileFOR WIN32

anima[aw]
Newbie Poster
1 post since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You