An open API service indexing awesome lists of open source software.

https://github.com/fuco1/ob-php

Fork of https://framagit.org/steckerhalter/ob-php.git
https://github.com/fuco1/ob-php

Last synced: about 2 months ago
JSON representation

Fork of https://framagit.org/steckerhalter/ob-php.git

Awesome Lists containing this project

README

          

README

/**
*
* @source: http://orgmode.org/org-info.js
*
* @licstart The following is the entire license notice for the
* JavaScript code in http://orgmode.org/org-info.js.
*
* Copyright (C) 2012-2013 Sebastian Rose
*
*
* The JavaScript code in this tag is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend The above is the entire license notice
* for the JavaScript code in http://orgmode.org/org-info.js.
*
*/

/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012-2013 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.

@licend The above is the entire license notice
for the JavaScript code in this tag.
*/

<!--/*--><![CDATA[/*><!--*/
org_html_manager.set("TOC_DEPTH", "3");
org_html_manager.set("LINK_HOME", "");
org_html_manager.set("LINK_UP", "");
org_html_manager.set("LOCAL_TOC", "1");
org_html_manager.set("VIEW_BUTTONS", "0");
org_html_manager.set("MOUSE_HINT", "#555555");
org_html_manager.set("FIXED_TOC", "0");
org_html_manager.set("TOC", "0");
org_html_manager.set("VIEW", "showall");
org_html_manager.setup(); // activate after the parameters are set
/*]]>*///-->

/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.

@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->


README



Table of Contents






1 ob-php






1.1 Org mode Babel support for PHP






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


    https://github.com/d11wtq/Boris


    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








1.1.2 Manual installation





  1. Load/evaluate the code and require ob-php

    (with-temp-buffer
    
    (url-insert-file-contents "https://raw.github.com/steckerhalter/ob-php/master/ob-php.el")
    (eval-buffer))
    (require 'ob-php)



  2. 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!








1.1.3 El-Get Recipe



(:name ob-php

:type http
:url "https://raw.github.com/steckerhalter/ob-php/master/ob-php.el"
:prepare (progn
(add-to-list 'org-babel-load-languages '(php . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)))
))





1.1.4 Usage




  1. No session

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


    mordor

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


    dude
    bear



  2. Pretty printing

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


    stdClass Object
    (
    [man] => green
    [pleora] => stdClass Object
    (
    )

    )




  3. Org output

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

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


    | forest | green |
    
    | sea | blue |




  4. 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"));
    


    array(2) {
    [0]=>
    string(6) "sonate"
    [1]=>
    string(9) "betthofen"
    }
    }


  5. Use previouly defined PHP variable

    print $x;
    


    PHP Notice: Array to string conversion in /home/reto/boris/lib/Boris/EvalWorker.php(133) : eval()'d code on line 1
    Array


  6. Why does this make an example block?

    var_dump($x);
    


    array(2) {
    ["mond"]=>
    string(6) "schein"
    [0]=>
    array(2) {
    [0]=>
    string(6) "sonate"
    [1]=>
    string(9) "betthofen"
    }
    }

    body { margin: 20px !important; }









Created: 2013-08-07 Wed 07:49


Emacs 24.3.50.1 (Org mode 7.9.3f)


Validate