Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Org mode Babel support for PHP
Emacs Lisp
branch: master
Failed to load latest commit information.
README.html fix html fix html
ob-php.el don't delete more than first match


Org mode Babel support for PHP

Prerequisites for Sessions

Per default Babel doesn’t use Sessions, so this is only needed for advanced operations…

  • boris - PHP Read Eval Print Loop (REPL)

    I wasted many hours trying to get the lousy PHP shell to work here (php -a). Then I discovered that it wasn’t even the real shell, but “interactive mode”. I have no idea why as =readline= was available.

    I also had to comment this in php.ini for Boris to work:

    ; disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
  • php-boris - an Emacs extension for Boris

    From MELPA, install via M-x package-install

    Currently only sessions with output work

Manual installation

Load/evaluate the code and require ob-php

  (url-insert-file-contents "")
(require 'ob-php)

Add PHP to the allowed languages for Babel

(add-to-list 'org-babel-load-languages '(php . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)

That’s it, you should be good to go!

El-Get Recipe

(:name ob-php
       :type http
       :url ""
       :prepare (progn
                  (add-to-list 'org-babel-load-languages '(php . t))
                  (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)))


No session

4 + 4;
print "dude\n";
print $x;
return $y;
4 + 4;
print "dude\n";
print $x;
return $y;

Pretty printing

$dude = new stdClass();
$dude->man = "green";
$dude->pleora = new stdClass();
return $dude;

Org output

$test = array(
    array('forest', 'green'),
    array('sea',  $sea),

foreach ($test as $row) {
    foreach($row as $cell) { print '|' . $cell; };
    print "\n";

Session with output

  • Note taken on [2013-08-06 Tue 01:43]
    This is wrong and should be fixed. The result is not really output!
$x = array("mond" => "schein", array("sonate", "betthofen"));

Use previouly defined PHP variable

print $x;

Why does this make an example block?


body { margin: 20px !important; }


Something went wrong with that request. Please try again.