Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile a PHP script in Linux

Tags:

linux

php

I know PHP scripts don't actually compile until they are run. However, say I want to create a small simple program and compile it to a binary without requiring the PHP binary. How could I do this?

I've seen a few IDE's out there that would do this, but either they are all for windows or the Linux versions don't actually build properly.
What I would like is something like py2exe that does it in the script itself.

like image 220
Botto Avatar asked Sep 07 '08 08:09

Botto


People also ask

How do I run a PHP script in Linux?

You can execute linux commands within a php script - all you have to do is put the command line in brackits (`). And also concentrate on exec() , this and shell_exec() .. Save this answer.

Can PHP scripts be compiled?

The short answer is "no". The current implementation of PHP is that of an interpreted language.

Can I run PHP script from command line?

You can run PHP scripts in the Command Line for a particular PHP version used in Plesk.


1 Answers

Check out phc: the PHP compiler

If you just want to run it like a script, you may not need to compile it per se, but just run it via the command line. Read running PHP via the command line.

like image 191
Chris Bartow Avatar answered Sep 26 '22 01:09

Chris Bartow