├── README.markdown ├── bootstrap-ee2.php ├── bootstrap-ee3.php ├── bootstrap-ee4.php └── composer.json /README.markdown: -------------------------------------------------------------------------------- 1 | # EE Bootstrap 2 | 3 | This file "bootstraps" the EE environment, so you use the `ee()` function to access the instance. 4 | 5 | Useful for little one off scripts, or cron jobs that need access to the EE environment. 6 | 7 | Example: 8 | 9 | ``` 10 | db->where('entry_date <', now() - (365*24*60*60)) 16 | ->update('channel_titles', array('status' => 'closed')); 17 | ``` 18 | 19 | ## Using with composer 20 | 21 | ``` 22 | composer require eecli/bootstrap ~1.2 23 | ``` 24 | 25 | ``` 26 | _assign_to_config($assign_to_config); 34 | } 35 | $UNI =& load_class('Utf8', 'core'); 36 | $URI =& load_class('URI', 'core'); 37 | $SEC =& load_class('Security', 'core'); 38 | $IN =& load_class('Input', 'core'); 39 | $OUT =& load_class('Output', 'core'); 40 | $LANG =& load_class('Lang', 'core'); 41 | $RTR =& load_class('Router', 'core'); 42 | 43 | $loader = load_class('Loader', 'core'); 44 | 45 | // Load the base controller class 46 | require BASEPATH.'core/Controller.php'; 47 | 48 | function &get_instance() 49 | { 50 | return CI_Controller::get_instance(); 51 | } 52 | 53 | function ee() 54 | { 55 | return get_instance(); 56 | } 57 | 58 | // required by the input class 59 | if ( ! isset($_SERVER['REMOTE_ADDR'])) 60 | { 61 | $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 62 | } 63 | 64 | new CI_Controller(); 65 | 66 | ee()->load->library('core'); 67 | 68 | if (method_exists(ee()->core, 'bootstrap')) { 69 | ee()->core->bootstrap(); 70 | } 71 | 72 | /* 73 | * ------------------------------------------------------ 74 | * Load the autoloader and register it 75 | * ------------------------------------------------------ 76 | */ 77 | require(APPPATH.'../EllisLab/ExpressionEngine/Core/Autoloader.php'); 78 | Autoloader::getInstance()->register(); 79 | 80 | // if you are loading template library or addon library you'll need this 81 | ee()->core->native_plugins = array('magpie', 'markdown', 'rss_parser', 'xml_encode'); 82 | ee()->core->native_modules = array('blacklist', 'channel', 'comment', 'commerce', 'email', 'emoticon', 'file', 'forum', 'ip_to_nation', 'jquery', 'mailinglist', 'member', 'metaweblog_api', 'moblog', 'pages', 'query', 'referrer', 'rss', 'rte', 'search', 'simple_commerce', 'stats', 'wiki'); 83 | 84 | ee()->load->library('remember'); 85 | ee()->load->library('localize'); 86 | ee()->load->library('session'); 87 | ee()->load->library('user_agent'); 88 | ee()->load->library('stats'); 89 | ee()->lang->loadfile('core'); 90 | ee()->load->helper('compat'); 91 | 92 | -------------------------------------------------------------------------------- /bootstrap-ee3.php: -------------------------------------------------------------------------------- 1 | addPrefix( 38 | 'EllisLab', 39 | $system_path.'ee/EllisLab/' 40 | ); 41 | 42 | $autoloader->addPrefix( 43 | 'Michelf', 44 | $system_path.'ee/legacy/libraries/typography/Markdown/Michelf/' 45 | ); 46 | 47 | $autoloader->register(); 48 | 49 | class EE3_Bootstrap extends EllisLab\ExpressionEngine\Core\ExpressionEngine 50 | { 51 | public function boot($assign_to_config = null) 52 | { 53 | parent::boot(); 54 | 55 | $app = $this->loadApplicationCore(); 56 | 57 | if (isset($assign_to_config)) { 58 | $this->overrideConfig($assign_to_config); 59 | } 60 | 61 | $this->getLegacyApp()->getFacade()->load->library('core'); 62 | 63 | $this->getLegacyApp()->getFacade()->core->bootstrap(); 64 | 65 | Controller::_setFacade($this->getLegacyApp()->getFacade()); 66 | 67 | new Controller(); 68 | } 69 | 70 | public static function getInstance() 71 | { 72 | static $instance; 73 | 74 | if (is_null($instance)) { 75 | $instance = new static; 76 | } 77 | 78 | return $instance; 79 | } 80 | } 81 | 82 | function get_instance() { 83 | return EE3_Bootstrap::getInstance()->getLegacyApp()->getFacade(); 84 | } 85 | 86 | function ee($make = null) { 87 | if (func_num_args() === 0) { 88 | return EE3_Bootstrap::getInstance()->getLegacyApp()->getFacade(); 89 | } 90 | 91 | return call_user_func_array([EE3_Bootstrap::getInstance()->getLegacyApp()->getFacade()->di, 'make'], func_get_args()); 92 | } 93 | 94 | EE3_Bootstrap::getInstance()->boot(isset($assign_to_config) ? $assign_to_config : null); 95 | -------------------------------------------------------------------------------- /bootstrap-ee4.php: -------------------------------------------------------------------------------- 1 |