示例#1
0
 public static function autoload($dir = NULL)
 {
     if ($dir) {
         self::$cache_dir = $dir;
     }
     return function ($class) {
         if (!($ret = DataBank::cached($class))) {
             $default = RocketSled::defaultAutoload();
             $ret = DataBank::cache($class, $default($class));
         }
         if ($ret) {
             require_once $ret;
         }
         return $ret;
     };
 }
 public static function runnable($rules_file, $base_dir, $rewrites_enabled)
 {
     if (file_exists($rules_file)) {
         require_once $rules_file;
         self::set_rules($rules);
     }
     //header_register_callback('rocket_path_parse_location_header');
     ob_start('rocket_path_parse_output_buffer');
     self::set_enabled(true);
     self::set_rewrites_enabled($rewrites_enabled);
     self::set_base_dir($base_dir);
     self::init_runnable_class();
     return RocketSled::defaultRunnable();
 }
<?php

require_once 'config.php';
//OVERRIDE THE DEFAULT AUTOLOAD TO PREVENT REPEATED
//DIRECTORY SCANNING IN A PRODUCTION ENVIRONMENT
RocketSled::autoload(DataBank::autoload());
//RUN THAT SHIT! http://www.youtube.com/watch?v=N_PX3DWH0nE
RocketSled::run();
示例#4
0
 public function run()
 {
     if (!($include = Args::get('include', Args::argv))) {
         $include = array();
     } else {
         $include = explode(',', $include);
     }
     if (!($exclude = Args::get('exclude', Args::argv))) {
         $exclude = array();
     } else {
         $exclude = explode(',', $exclude);
     }
     if (!($dbconfig_path = Args::get('dbconfig', Args::argv)) || !($dbconfig = (include $dbconfig_path))) {
         echo "You need to include 'dbconfig' in the command line arguments." . PHP_EOL;
         echo "The file should have the following format: " . PHP_EOL;
         echo "<?php" . PHP_EOL;
         echo "return array('db_host' => 'localhost'," . PHP_EOL;
         echo "             'db_user' => 'root'," . PHP_EOL;
         echo "             'db_pass' => 'root'," . PHP_EOL;
         echo "             'db_name' => 'killerapp'," . PHP_EOL;
         echo "             'db_port' => 3309" . PHP_EOL;
         echo "?>" . PHP_EOL;
         echo PHP_EOL;
         echo "Usage: php index.php Murphy dbconfig=/path/to/dbconfig.php" . PHP_EOL;
         exit(1);
     }
     $tests = RocketSled::filteredPackages(function ($arg) {
         $ret = FALSE;
         if (RocketSled::endsWith($arg, '.run.php')) {
             $ret = $arg;
         }
         return $ret;
     });
     foreach ($tests as $path) {
         if (count($include)) {
             $use = FALSE;
         } else {
             $use = TRUE;
         }
         foreach ($exclude as $exc) {
             if (strpos(realpath($path), realpath($exc)) === 0) {
                 $use = FALSE;
             }
         }
         foreach ($include as $inc) {
             if (strpos(realpath($path), realpath($inc)) === 0) {
                 $use = TRUE;
             }
         }
         if (strpos($path, '.murphy/') === FALSE) {
             $use = FALSE;
         }
         if ($use) {
             $output = '';
             exec('php index.php "Murphy\\Test" path=' . escapeshellarg($path) . ' dbconfig=' . escapeshellarg(Args::get('dbconfig', Args::argv)), $output, $exit_code);
             if ($exit_code) {
                 echo 'FATAL ERROR: ' . $path . ' terminated abnormally' . PHP_EOL;
             }
             echo PHP_EOL . '====Output from ' . $path . '===========' . PHP_EOL;
             foreach ($output as $opline) {
                 echo $opline . PHP_EOL;
             }
             echo PHP_EOL . '=====================================' . PHP_EOL;
         }
     }
 }
示例#5
0
<?php

spl_autoload_register(function () {
    if (!class_exists('RocketSled')) {
        require_once dirname(__FILE__) . '/rocket_sled.class.php';
        RocketSled::instance();
    }
});
 private static function packages()
 {
     if (self::$packages === NULL) {
         self::$packages = array();
         foreach (self::$scan as $dir) {
             $list = self::directoryList($dir);
             if (is_array($list) && count($list)) {
                 self::$packages = array_merge(self::$packages, $list);
             }
         }
     }
     return self::$packages;
 }
<?php

//REQUIRED CONFIG FILES
require_once 'dirs.php';
require_once $dirs[$current_hostname]['rs'] . 'RocketSled/rocket_sled.class.php';
//IF YOU HAVE ANY AUTOLOADS TO INCLUDE THAT AREN'T AUTOMATICALLY COVERED
//BY RocketSled OR NEED TO BE PERFORMED BEFORE RocketSled REGISTERS
//NB: USING include_once HERE SO WE CAN USE THE SAME CONFIG FILE WHEN
//    RUNNING install.php
include_once $dirs[$current_hostname]['rs'] . 'DataBank/data_bank.class.php';
//TELL THE RocketSled AUTOLOADER WHERE TO LOOK FOR STUFF
RocketSled::scan($dirs[$current_hostname]);