Skip to content

Instantly share code, notes, and snippets.

@rsanchez
Created April 28, 2012 16:37
Show Gist options
  • Save rsanchez/2520130 to your computer and use it in GitHub Desktop.
Save rsanchez/2520130 to your computer and use it in GitHub Desktop.
PHP CLI (or CodeRunner) bootstrap into EE

#Bootstrap EE in PHP CLI

Use the bootstrapper and php auto-prepend your bootstrap file:

In my .profile I have this alias.

alias ee='php -a -d auto_prepend_file="/path/to/your/bootstrap.php"'

Now in the terminal I enter the command ee and I have an interactive PHP cli with access to my local EE environment. If you are using virtual hosts and have many local EE environments, use multiple aliases/bootstrap files.

In CodeRunner:

  • Go to Preferences > Languages
  • Duplicate PHP, call it EE
  • Change your run command to: php -d auto_prepend_file='/path/to/your/bootstrap.php' $filename
<?php
//system path for this site
$system_path = '/Users/foo/Sites/site_name/system/';
//local path to main bootstrap file
include_once '/Users/foo/Repos/ExpressionEngine-Bootstrap/bootstrap-ee2.php';
//why not?
$EE->load->helper(array('file', 'array', 'url', 'xml', 'string', 'inflector', 'text', 'html', 'form', 'directory', 'download'));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment