Exemple #1
0
 public function executeWrapper(array $args)
 {
     if (empty($args)) {
         $args = [null];
         // $args = ['app.phpsgi'];
     }
     list($appFile) = $args;
     $logger = new Logger();
     if ($appFile) {
         if (!file_exists($appFile)) {
             die("File {$appFile} doesn't exist.");
         }
         $app = (require $appFile);
     } else {
         $app = function (array &$environment, array $response) {
             return [200, ['Content-Type' => 'text/plain'], 'Hello World'];
         };
     }
     if (extension_loaded('event')) {
         $logger->info("Found 'event' extension, enabling EventHttpServer server.");
         $server = new EventHttpServer($app);
     } else {
         $logger->info("Falling back to StreamSocketServer server.");
         $server = new StreamSocketServer($app);
     }
     return $server->listen();
 }
 /**
  * @param $body
  */
 public function basicPublish($body)
 {
     try {
         $this->getChannel()->basic_publish($this->message->setBody(json_encode($body)), '', $this->queue_name);
         $this->logger->info('Job published successfully!');
     } catch (\AMQPChannelException $e) {
         $this->logger->error($e->getMessage());
     }
 }
Exemple #3
0
 /**
  * @param Logger       $logger
  * @param OptionResult $options
  * @param string       $downloader
  *
  * @return BaseDownloader
  */
 public static function getInstance(Logger $logger, OptionResult $options, $downloader = null)
 {
     if (is_string($downloader)) {
         //if we specific a downloader class clearly, then it's the only choice
         if (class_exists($downloader) && is_subclass_of($downloader, 'PhpBrew\\Downloader\\BaseDownloader')) {
             return new $downloader($logger, $options);
         }
         $downloader = array($downloader);
     }
     if (empty($downloader)) {
         $downloader = array_keys(self::$availableDownloaders);
     }
     //if --downloader presents, we will use it as the first choice, even if the caller specific downloader by alias/array
     if ($options->has('downloader')) {
         $logger->info("Found --downloader option, try to use {$options->downloader} as default downloader.");
         $downloader = array_merge(array($options->downloader), $downloader);
     }
     $instance = self::create($logger, $options, $downloader);
     if ($instance === null) {
         $logger->debug('Downloader not found, falling back to command-based downloader.');
         //if all downloader not available, maybe we should throw exceptions here instead of returning null?
         return self::create($logger, $options, self::$fallbackDownloaders);
     } else {
         return $instance;
     }
 }
Exemple #4
0
 /**
  * Disable extensions known to conflict with current one
  */
 public function disableAntagonists()
 {
     $name = $this->meta->getName();
     if (isset($this->conflicts[$name])) {
         $conflicts = $this->conflicts[$name];
         $this->logger->info("===> Applying conflicts resolution (" . implode(', ', $conflicts) . "):");
         foreach ($conflicts as $extension) {
             $e = new Extension($extension, $this->logger);
             $e->disable();
         }
     }
 }
 public function importSchema($schema)
 {
     $this->logger->info('Importing schema: ' . get_class($schema));
     if ($schema instanceof DeclareSchema) {
         $sqls = $this->builder->build($schema);
         $this->query($sqls);
     } elseif ($schema instanceof BaseModel && method_exists($schema, 'schema')) {
         $model = $schema;
         $schema = new DynamicSchemaDeclare($model);
         $sqls = $this->builder->build($schema);
         $this->query($sqls);
     } else {
         throw new InvalidArgumentException('Unsupported schema type');
     }
 }
Exemple #6
0
<?php

$loader = (require "vendor/autoload.php");
require "tests/model_helpers.php";
mb_internal_encoding('UTF-8');
error_reporting(E_ALL);
$loader->add(null, 'tests');
$loader->add(null, 'tests/src');
use LazyRecord\Schema\SchemaGenerator;
use LazyRecord\ConfigLoader;
use CLIFramework\Logger;
$config = ConfigLoader::getInstance();
$config->loadFromSymbol(true);
$config->initForBuild();
$logger = new Logger();
$logger->quiet();
$logger->info("Building schema class files...");
// build schema class files
$schemas = array(new \AuthorBooks\Model\AddressSchema(), new \AuthorBooks\Model\AuthorBookSchema(), new \AuthorBooks\Model\AuthorSchema(), new \AuthorBooks\Model\BookSchema(), new \AuthorBooks\Model\PublisherSchema(), new \AuthorBooks\Model\TagSchema(), new \MetricApp\Model\MetricValueSchema(), new \PageApp\Model\PageSchema(), new \StoreApp\Model\StoreSchema(), new \TestApp\Model\EdmSchema(), new \TestApp\Model\IDNumberSchema(), new \TestApp\Model\NameSchema(), new \TestApp\Model\PostSchema(), new \TestApp\Model\TableSchema(), new \TestApp\Model\UserSchema(), new \TestApp\Model\WineCategorySchema(), new \TestApp\Model\WineSchema());
$g = new \LazyRecord\Schema\SchemaGenerator($config, $logger);
$g->setForceUpdate(true);
$g->generate($schemas, true);
// $logger->info("Starting tests...");
 public function finish()
 {
     if ($this->options->profile) {
         $this->logger->info(sprintf('Memory usage: %.2fMB (peak: %.2fMB), time: %.4fs', memory_get_usage(true) / (1024 * 1024), memory_get_peak_usage(true) / (1024 * 1024), microtime(true) - $this->startedAt));
     }
 }