18

I'm not much of a programmer, PHP is where I'm comfortable. And sometimes I find that I need to do things, such as arrange files or rename files on a mass scale on my computer. And I think I could do this with PHP but I can't of course.

So I was curious, is there a way I could run PHP files as kind of exe files.

EDIT: Fairly important point, using Windows.

3
  • 1
    I like your question - it's interesting. Just for fun, I started a related question - "Why NOT use PHP as a desktop programming language?" stackoverflow.com/questions/1609167/… Commented Oct 22, 2009 at 18:40
  • I believe PHP Nightrain is your answer. You can create GUI apps in PHP, HTML, CSS, Javascript, etc... naetech.com/php-nightrain Commented Aug 1, 2014 at 22:32
  • I think you should consider learning a real programming language. Using PHP is like using crayons to draft professional blueprints for a building. Commented Jan 2, 2023 at 5:14

13 Answers 13

7

just use php.exe (put it in your path) and the name of the php file you want to execute

Sign up to request clarification or add additional context in comments.

2 Comments

e.g. Put it in c:\windows\system32
gaz: The proper way is to use the PATH environment variable (config->system->env variables). But your method (although crude) might work also
6

You should have a look at php gtk

2 Comments

This is also not what he is asking about
He might want to make a GUI for his "desktop application".
3

It's not as bad as you put it. PHP may be a very good tool for string related stuff like parsing, renaming etc. Especially if you know PHP.

To use php as script you should add #!/path/to/php as first line and set execution permissions on unixoid systems. In windows you can simply assign the php file ending with your php cli exe so you can click on them or use the script with the "start" command in the windows shell. But make sure that you write your scripts in a way that it is sensible to the current working directory. It may be different to what you might expect sometimes.

Comments

2

to be able to execute php files with double click, just like normal programs, go to the command line, then type

ftype php_script "C:\path\to\php.exe" "%1"
assoc .php=php_script

Comments

2

Check out WinBinder

Comments

1

Sure, just add #!/path/to/php to the top of the file, add the code in tags, and run it as a shell script.

Works fine - the php binary you use is either the cgi one or the purpose built CLI version.

http://www.php-cli.com/

http://php.net/manual/en/features.commandline.php

2 Comments

Works in windows as well , the path would just be different
How would a shell script work on windows? Some how I doubt the instructions here work for that.
1

it would appear so, yes.

1 Comment

That's not exactly what he is asking about.
1

Download Wamp Server, install it. Once thats done, add the path to the php.exe to your PATH settings. You can do this by going to control panel->system->change settings->advanced->environment variables. Edit the PATH, add a ';' to the end of the line and then past the path to the php.exe. This is on Vista, it might be different on XP or Windows 7.

My path looks like this after: C:\Sun\SDK\jdk\bin;C:\wamp\bin\php\php5.3.0

Once thats done, you'll be able to execute a php file from the command line. You could create shortcuts too.

C:\Users\Garth Michel>php test.php

This is a test

C:\Users\Garth Michel>

I used php for years as a scripting language before I even bothered to use it as a web programming language.

Comments

0

maybe php is not the right tool to doing this and it's about time to learn another language...use this chance to expand your programming horizion

5 Comments

php works just fine for these things. Would safe him a lot of time learning something different. Expanding one's programming horizon is never a bad idea, just do it for the good reasons ;^)
doing file operation in a desktop environment with a script language (which focus on websites/server use) is a good reason for me ;)
@Jochen Hilgers So I should scrap all of my PHP desktop scripts (some of which I've been using for years, and some of which do complex file operations, both local and network)?
no one said that... Ben Shelock has no existing scripts and so i see it as a good opportunity to learn something new ( if there is enough time and passion)
I think the "simplicity" rule overshadows the "learn a new language for it" idea.
0

See the .reg file in this gist, it makes it possible to use .php files exactly like .bat files, e.g. my_script.php foo bar baz

Don't forget to edit paths to suit your setup.

Comments

0

http://www.appcelerator.com/products/download/ Still use html & css as a desktop app and now has support for php.

Comments

0

PHP based web apps like Wordpress and Mediawiki I think uses php to setup and configure itself. Just give IIS proper read/write rights and you can make a simple web app that does massive renaming, etc.. PHP doesn't have to always be used for writing out html.

Comments

0

See ExeOutput for PHP. It has excellent customization and MAGNIFICENT features. Yet it is not an IDE or something. It compiles your PHP+HTML into fully-fledged EXEs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.