Skip to content

Instantly share code, notes, and snippets.

@Vinai
Last active September 10, 2016 15:33
Show Gist options
  • Save Vinai/5579309 to your computer and use it in GitHub Desktop.
Save Vinai/5579309 to your computer and use it in GitHub Desktop.
PHP REPL with initialized Magento environment
#!/usr/bin/env php
<?php
//
// PHP REPL with initialized Magento environment
//
// Thanks to https://github.com/d11wtq/boris
//
// Drop this script in your $PATH and run it anywhere in a Magento directory tree to start the REPL
//
$mageFile = 'app/Mage.php';
for ($i = 0, $d = './'; ! file_exists($d.$mageFile) && ++$i < 25; $d .= '../');
if (! file_exists($d.$mageFile)) {
echo "Unable to find $mageFile" . PHP_EOL;
exit(2);
}
chdir($d); // Magento needs the pwd to be the magento base dir
// Search for boris in PHP's default include path and Magento's lib directory
set_include_path(get_include_path().':'.getcwd().'/lib');
require_once 'boris/lib/autoload.php';
umask(0);
require_once $mageFile;
Mage::setIsDeveloperMode(true);
Mage::app('admin');
$boris = new \Boris\Boris('mage> ');
$boris->start();
@Vinai
Copy link
Author

Vinai commented May 15, 2013

@RSully
Copy link

RSully commented Jun 16, 2014

Hrm, any ideas how to use this with a global install of boris (brew install boris)?

@Vinai
Copy link
Author

Vinai commented Jul 19, 2014

The only difference would be on line 24, where boris is required.

@martisj
Copy link

martisj commented Jan 6, 2015

I've installed boris with composer g require d11wtq/boris:@stable how on earth do I get it working? IR baboon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment