public function handle()
 {
     $this->checkArgs(array('table'));
     $namespace = array_key_exists('namespace', $this->args) ? $this->args['namespace'] : null;
     if (!isset($namespace)) {
         $namespace = array_key_exists('ns', $this->args) ? $this->args['ns'] : null;
     }
     $table = $this->args['table'];
     $class = array_key_exists('class', $this->args) ? $this->args['class'] : Strings::snakeToCamel($table);
     $path = $this->path($class, $namespace);
     $schema = new TableSchema($table);
     if (file_exists($path)) {
         $content = File::readText($path);
         $className = isset($namespace) ? "{$namespace}\\{$class}" : $class;
         $reflection = new \ReflectionClass($className);
         $header = $reflection->getDocComment();
         if (isset($header)) {
             $content = str_replace($header, Template::generateHeader($schema->columns()), $content);
             unlink($path);
             File::writeText($path, $content);
         }
         Console::line("Model [{$class}] updated in path [{$path}].");
     } else {
         File::writeText($path, Template::generateModel($table, $class, $schema->columns(), $namespace));
         Console::line("Model [{$class}] created in path [{$path}].");
     }
 }
Esempio n. 2
0
 public static function get($path)
 {
     if (isset($path) && is_readable($path)) {
         return File::readText($path);
     }
     return null;
 }
Esempio n. 3
0
 private function makeMigration()
 {
     if (!isset($this->args[1])) {
         throw new ConsoleException("Invalid migration argument in [--make].");
     }
     $migration = $this->args[1];
     $author = isset($this->args[2]) ? $this->args[2] : "Unknown";
     $class = 'm' . time() . Strings::snakeToCamel($migration);
     $path = App::path('migration') . "/{$class}.php";
     File::writeText($path, Template::generate($class, $author));
     Console::line("migration [{$migration}] finished in [{$class}.php].");
 }
Esempio n. 4
0
 private function createPidFile()
 {
     File::writeText($this->pidFilePath, posix_getpid());
 }
Esempio n. 5
0
 public function beforeStop()
 {
     File::appendText(App::path('cache') . "/" . get_called_class() . "_stop.log", $this->getPID() . "_" . posix_getpid() . "_" . time() . "\r\n");
 }
Esempio n. 6
0
 private function writeCache()
 {
     File::writeText($this->source, serialize($this));
 }
Esempio n. 7
0
<?php

/**
 * Created by PhpStorm.
 * User: lbob
 * Date: 2015/12/8
 * Time: 14:25
 */
use Xaircraft\Core\IO\File;
use Xaircraft\Exception\DaemonException;
use Xaircraft\Exception\HttpAuthenticationException;
return array(HttpAuthenticationException::class => function ($ex) {
    var_dump("aa");
}, DaemonException::class => function ($ex) {
    $path = \Xaircraft\App::path('log') . "/daemon/" . date("Ymd", time()) . '.log';
    File::appendText($path, $ex->getMessage);
});