0

I want to install the php-mode on my windows 7 machine. I went through documentation of the cited website and there is no mention of what should be extra required to run this mode. Obviously, the PHP interpreter and some server, I would like to use MySQL as well. So what is the best setup to have them all (please cite the download websites where necessary). I know there are all-in-one installers for Windows like XAMPP, but what other workflows and alternatives are there other than that? What is recommended with regards to an effective Emacs ecosystem? I am just unaware of the possibilities.

What is special about installation of this mode in Windows apart from:

require ('php-mode)  

in the dot emacs file?

I want also to indent an HTML content inside a PHP construct. I mean indentation of something similar to the MWE below:

MWE -- page.php inside templates folder

<?php
return "<!DOCTYPE html>
<html>
<head>
    <title>$pageData->title</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
  </head>
  <body>
    $pageData->content
  </body>
</html>";
?>

It might be helpful to share part of the dot emacs file code related only to php-mode. Thanks.

Notes

  • I added the c:\xampp\php\php.exe to PATH variables but when I press C-c C-r of php code it throws this error: php-send-region: Searching for program: no such file or directory, php

Update There was a bug and thankfully fixed by the developer: https://github.com/ejmr/php-mode/issues/228#issuecomment-77057035. Now, after applying the fix in the source and setting the PATH variable correctly in Windows to c:\xampp\php instead of c:\xampp\php\php.exe, C-c C-r is generating the *PHP* buffer.

Question
How to show the output of PHP code from the *PHP* buffer? What is the workflow to show the output in whatever browser available?

5
  • See the variable php-executable at line 110 of the current Github source code: github.com/ejmr/php-mode/blob/master/php-mode.el The default is /usr/bin/php. So, you may want to try: (setq php-executable "c:\xampp\php.exe") -- that being said, it's been about 15 years since I played with php / mysql / etc on Windows and I really don't remember how I eventually set that up, sorry. In terms of indenting, I like to manually indent and have visual vertical lines help me with how things should line up, however, most people seem to prefer auto-indentation. Commented Mar 2, 2015 at 17:10
  • I M-x customize group -> php -> php-executable to c:\xampp\php.exe didn't solve it. Still throwing exactly the same error. Commented Mar 2, 2015 at 21:02
  • I see that line 1444 uses: (call-process "php" nil php-buffer nil "-r" cleaned-php-code)))). Now that you have set the php-executable correctly, you can substitute "php" with the variable without quotation marks: (call-process php-executable nil php-buffer nil "-r" cleaned-php-code)))) That should do the trick, but you'd need to modify the source, and if needed, re-byte-compile. Alternatively, you can keep fiddling around with the path in an effort to help call-process find your php executable. Commented Mar 2, 2015 at 22:29
  • @lawlist, now a step forward, C-c C-r works by generating a the *PHP* buffer but how to show the output in the browser from there? Any help would be much appreciated if you still remember your workflow under Windows. Thanks. Commented Mar 5, 2015 at 12:24
  • Here are a couple of very basic examples using start-process on Windows XP -- I haven't ever used php-mode. The following example contemplates the existence of a php file in the webserver directory named test.php: (start-process "process-name" nil "c:/Program Files/Internet Explorer/IEXPLORE.EXE" "http://localhost/test.php") The following example contemplates the existence of an html file anywhere on the computer that is readable: (start-process "process-name" nil "c:/Program Files/Internet Explorer/IEXPLORE.EXE" "y:/.0.lawlist.git/public_html/index.html") Commented Mar 6, 2015 at 4:33

0

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.