mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT: Proof-of-concept REPL for sapphire
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@67153 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
17e855da88
commit
5c32415664
@ -28,7 +28,8 @@ Director::addRules(10, array(
|
|||||||
'sitemap.xml' => 'GoogleSitemap',
|
'sitemap.xml' => 'GoogleSitemap',
|
||||||
'api/v1' => 'RestfulServer',
|
'api/v1' => 'RestfulServer',
|
||||||
'soap/v1' => 'SOAPModelAccess',
|
'soap/v1' => 'SOAPModelAccess',
|
||||||
'dev' => 'DevelopmentAdmin'
|
'dev' => 'DevelopmentAdmin',
|
||||||
|
'interactive' => 'SapphireREPL',
|
||||||
));
|
));
|
||||||
|
|
||||||
Director::addRules(1, array(
|
Director::addRules(1, array(
|
||||||
|
23
dev/SapphireREPL.php
Normal file
23
dev/SapphireREPL.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SapphireREPL extends Controller {
|
||||||
|
function index() {
|
||||||
|
if(!Director::is_cli()) return "The Sapphire Interactive Command-line doesn't work in a web browser. Use 'sake interactive' from the command-line to run.";
|
||||||
|
|
||||||
|
echo "Sapphire Interactive Command-line (REPL interface)\n\n";
|
||||||
|
while(true) {
|
||||||
|
echo "?> ";
|
||||||
|
$command = trim(fgets(STDIN, 4096));
|
||||||
|
|
||||||
|
// Simple processing
|
||||||
|
if(substr($command,-1) == ';') $command = substr($command,0,-1);
|
||||||
|
if(!preg_match('/^return/i', $command)) $command = "return ($command)";
|
||||||
|
$command .= ";";
|
||||||
|
$result = eval($command);
|
||||||
|
print_r($result);
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user