Example #1
0
    $error = error_get_last();
    if (!empty($error)) {
        ob_clean();
        $errstr = $error['message'];
        $errline = $error['line'];
        $errfile = $error['file'];
        $errorOutput($errstr, $errline, $errfile, debug_backtrace());
    }
};
$exceptionHandler = function ($e) use($errorOutput) {
    ob_clean();
    $message = $e->getMessage();
    $line = $e->getLine();
    $file = $e->getFile();
    $errorOutput($message, $line, $file, $e->getTrace());
    die;
};
//Run the framework!
$framework->bootstrap();
set_error_handler($errorHandler);
set_exception_handler($exceptionHandler);
register_shutdown_function($shutdownHandler);
//If you want to delete alias cache on every run, set deleteAliases in config.php to true
//Add an alias to the app, which enables you to run container operations within "alias" alias as shown below
Container::open('aliases')->add('alias', Container::open('aliases'));
//now we can use Storage:: alias to operate specific container instance
Alias::add('storage', Container::open('storage'));
/*
	Your code goes down here 
*/
require 'app.php';
 protected function importAlias()
 {
     $this->truncateTables(array('alias'));
     $handle = $this->openCsvFile('alias.csv');
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
         $res = false;
         $fields = $this->filterFields('Alias', $this->alias_fields, $line);
         if (!isset($fields['id'])) {
             $alias = new Alias((int) $line[0]);
             $alias->id = $line[0];
         } else {
             $alias = new Alias((int) $fields['id']);
         }
         foreach ($fields as $key => $field) {
             $alias->{$key} = $field;
         }
         $alias->force_id = true;
         if (!$res) {
             $alias->add();
         }
     }
     $this->closeCsvFile($handle);
     return true;
 }