PHP Classes

File: base/cmd

Recommend this page to a friend!
  Packages of Carlos Eduardo Barcelos Amaral   Base MVC Framework   base/cmd   Download  
File: base/cmd
Role: Example script
Content type: text/plain
Description: Example script
Class: Base MVC Framework
MVC framework to be the base of Web applications
Author: By
Last change: Some fix and email test

Date: 8 years ago
Size: 1,858 bytes
 

Contents

Class file image Download
<?php

include dirname(__DIR__).'/vendor/autoload.php';
include __DIR__.'/config/loader.php';

$cmd = new CMP\Console();

function myErrorHandler($errno, $errstr, $errfile, $errline) {
   global $cmd;
   $description = '';
    switch ($errno) {
      case E_ERROR:
      case E_CORE_ERROR:
      case E_COMPILE_ERROR:
      case E_USER_ERROR:
         $description = "<error> ERROR </error> $errstr\n";
         $description .= "  Fatal error on line <info>$errline</info> in file <info>$errfile</info>";
         $description .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
         $description .= "Aborting...\n";
         break;

      case E_WARNING:
      case E_USER_WARNING:
         $description = "<warning> WARNING </warning> $errstr\n";
         $description .= "  on line <info>$errline</info> in file <info>$errfile</info>";
         $description .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
         break;

      case E_NOTICE:
      case E_USER_NOTICE:
      $description = "<warning> NOTICE </warning> $errstr\n";
      $description .= "  on line <info>$errline</info> in file <info>$errfile</info>";
      $description .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
         break;

      default:
      return false;
         break;
    }

    $cmd->writeln($description);
    /* Don't execute PHP internal error handler */
    return true;
}

$old_error_handler = set_error_handler("myErrorHandler");

$cmd->register('environment', new \Console\Commands\Environment);
$cmd->register('dump-routes', new \Console\Commands\DumpRoutes);
$cmd->alias('environment', 'env');
$cmd->register('build', new \Console\Commands\Build);
$cmd->register('test-email', new \Console\Commands\TestEmail);


try {
   $cmd->run();
} catch (\Exception $e) {
   $cmd->writeln("Exception: <error>{$e->getMessage()}</error>");
   exit(1);
}

exit(0);