File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env php
22<?php
33
4- /**
5- * Set environment
6- */
74define ('MAD_ENV ' , isset ($ _SERVER ['MAD_ENV ' ]) ? $ _SERVER ['MAD_ENV ' ] : 'development ' );
8- require_once dirname (dirname (__FILE__ )).'/config/environment.php ' ;
95
10- print "Loading " .MAD_ENV ." environment (Mad 1.0) \n" ;
6+ echo "Loading " .MAD_ENV ." environment \n" ;
117
12- $ f = fopen ('php://stdin ' , 'r ' );
13-
14- $ buffer = '' ;
15- while (true ) {
16- print '>> ' ;
17- $ input = chop (fgets ($ f , 1024 ));
18- if ($ input == 'quit ' || $ input == 'exit ' ) { fclose ($ f ); exit ; }
19-
20- // buffer the input
21- $ buffer .= " $ input " ;
22-
23- // @todo - use a regexp to make sure brace char is not in a string
24- $ opening = substr_count ($ buffer , '{ ' );
25- $ closing = substr_count ($ buffer , '} ' );
26-
27- // evaluate expression if we've closed all braces
28- if ($ closing >= $ opening && $ buffer != ' ' ) {
29- try {
30- $ result = 'null ' ;
31- if (!strstr ($ buffer , '{ ' )) {
32- eval ("\$result = $ buffer " );
33- } else {
34- eval ($ buffer );
35- }
36- // print result of expression
37- print "=> $ result \n" ;
38-
39- } catch (Exception $ e ) {
40- print get_class ($ e ).": " .$ e ->getMessage ()."\n" .
41- ' from: ' .$ e ->getFile ().': ' .$ e ->getLine ()."\n" ;
42-
43- }
44- $ buffer = '' ;
45- }
46- }
8+ putenv ('MAD_ENV= ' . MAD_ENV );
9+ pcntl_exec (PHP_BINARY , [
10+ '-d ' , 'auto_prepend_file= ' . dirname (__DIR__ ) . '/config/environment.php ' ,
11+ '-a '
12+ ]);
You can’t perform that action at this time.
0 commit comments