コード例 #1
0
ファイル: DownloadFactory.php プロジェクト: phpbrew/phpbrew
 /**
  * @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;
     }
 }
コード例 #2
0
 public function testPatch()
 {
     if (PHP_OS !== "Darwin") {
         return $this->markTestSkipped('openssl DSO patch test only runs on darwin platform');
     }
     $logger = new Logger();
     $logger->setQuiet();
     $fromVersion = '5.5.17';
     $sourceFixtureDirectory = getenv('PHPBREW_FIXTURES_PHP_DIR') . DIRECTORY_SEPARATOR . $fromVersion;
     $sourceDirectory = getenv('PHPBREW_BUILD_PHP_DIR');
     $this->setupBuildDirectory($fromVersion);
     $build = new Build($fromVersion);
     $build->setSourceDirectory($sourceDirectory);
     $build->enableVariant('openssl');
     $this->assertTrue($build->hasVariant('openssl'), 'openssl enabled');
     $patch = new OpenSSLDSOPatch();
     $matched = $patch->match($build, $logger);
     $this->assertTrue($matched, 'patch matched');
     $patchedCount = $patch->apply($build, $logger);
     $this->assertEquals(10, $patchedCount);
     /*
             We can't assume the file equals because the test may be run on different platform and openssl may be installed 
             into different locations.
     
             $sourceExpectedDirectory = getenv('PHPBREW_EXPECTED_PHP_DIR') . DIRECTORY_SEPARATOR . '5.5.17-openssl-dso-patch';
             $this->assertFileEquals($sourceExpectedDirectory. '/Makefile', $sourceDirectory . '/Makefile');
     */
 }
コード例 #3
0
ファイル: Console.php プロジェクト: phpsgi/funk
 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();
 }
コード例 #4
0
 public function testPatch()
 {
     $logger = new Logger();
     $logger->setQuiet();
     $fromVersion = '5.3.29';
     $sourceFixtureDirectory = getenv('PHPBREW_FIXTURES_PHP_DIR') . DIRECTORY_SEPARATOR . $fromVersion;
     $sourceDirectory = getenv('PHPBREW_BUILD_PHP_DIR');
     if (!is_dir($sourceDirectory)) {
         return $this->markTestSkipped("{$sourceDirectory} does not exist.");
     }
     // Copy the source Makefile to the Makefile
     // copy($sourceFixtureDirectory . '/Makefile', $sourceDirectory . '/Makefile');
     $this->setupBuildDirectory($fromVersion);
     $build = new Build($fromVersion);
     $build->setSourceDirectory($sourceDirectory);
     $build->enableVariant('intl');
     $this->assertTrue($build->hasVariant('intl'), 'intl enabled');
     $patch = new IntlWith64bitPatch();
     $matched = $patch->match($build, $logger);
     $this->assertTrue($matched, 'patch matched');
     $patchedCount = $patch->apply($build, $logger);
     $this->assertEquals(3, $patchedCount);
     $sourceExpectedDirectory = getenv('PHPBREW_EXPECTED_PHP_DIR') . DIRECTORY_SEPARATOR . $fromVersion;
     $this->assertFileEquals($sourceExpectedDirectory . '/Makefile', $sourceDirectory . '/Makefile');
 }
コード例 #5
0
 /**
  * @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());
     }
 }
コード例 #6
0
 public function test()
 {
     $logger = new Logger();
     $logger->setQuiet();
     $workingDir = new SplFileInfo(getcwd());
     $vendorDirName = 'vendor';
     $autoloadGenerator = new ComposerAutoloadGenerator($logger);
     $autoloadGenerator->setVendorDir('vendor');
     $autoloadGenerator->setWorkingDir($workingDir->getPathname());
     $autoloadGenerator->scanComposerJsonFiles($workingDir . DIRECTORY_SEPARATOR . $vendorDirName);
 }
コード例 #7
0
ファイル: KnownCommandTest.php プロジェクト: JoeHorn/phpbrew
 public function testBitbucketPackage()
 {
     $logger = new Logger();
     $logger->setQuiet();
     $provider = new BitbucketProvider();
     $provider->setOwner('osmanov');
     $provider->setRepository('pecl-event');
     $provider->setPackageName('event');
     $extensionDownloader = new ExtensionDownloader($logger, new OptionResult());
     $versionList = $extensionDownloader->knownReleases($provider);
     $this->assertNotCount(0, $versionList);
 }
コード例 #8
0
 /**
  * @dataProvider packageNameProvider
  */
 public function testInstallPackages($extensionName, $extensionVersion = 'latest')
 {
     $logger = new Logger();
     $logger->setDebug();
     $manager = new ExtensionManager($logger);
     $peclProvider = new PeclProvider();
     $downloader = new ExtensionDownloader($logger, new OptionResult());
     $peclProvider->setPackageName($extensionName);
     $downloader->download($peclProvider, $extensionVersion);
     $ext = ExtensionFactory::lookup($extensionName);
     $this->assertNotNull($ext);
     $manager->installExtension($ext, array());
 }
コード例 #9
0
 /**
  * @dataProvider packageNameProvider
  */
 public function testInstallPackages($build, $extensionName, $extensionVersion, $options)
 {
     if (!$build) {
         $this->markTestSkipped('skip extension build test');
         return;
     }
     $logger = new Logger();
     $logger->setDebug();
     $manager = new ExtensionManager($logger);
     $peclProvider = new PeclProvider();
     $downloader = new ExtensionDownloader($logger, new OptionResult());
     $peclProvider->setPackageName($extensionName);
     $downloader->download($peclProvider, $extensionVersion);
     $ext = ExtensionFactory::lookup($extensionName);
     $this->assertNotNull($ext);
     $manager->installExtension($ext, $options);
 }
コード例 #10
0
 public function testPatch()
 {
     $logger = new Logger();
     $logger->setQuiet();
     $fromVersion = '5.5.17';
     $sourceFixtureDirectory = getenv('PHPBREW_FIXTURES_PHP_DIR') . DIRECTORY_SEPARATOR . $fromVersion;
     $sourceDirectory = getenv('PHPBREW_BUILD_PHP_DIR');
     if (!is_dir($sourceDirectory)) {
         return $this->markTestSkipped("{$sourceDirectory} does not exist.");
     }
     $this->setupBuildDirectory($fromVersion);
     $build = new Build($fromVersion);
     $build->setSourceDirectory($sourceDirectory);
     $build->enableVariant('apxs2');
     $this->assertTrue($build->hasVariant('apxs2'), 'apxs2 enabled');
     $patch = new Apache2ModuleNamePatch();
     $matched = $patch->match($build, $logger);
     $this->assertTrue($matched, 'patch matched');
     $patchedCount = $patch->apply($build, $logger);
     $this->assertEquals(107, $patchedCount);
     $sourceExpectedDirectory = getenv('PHPBREW_EXPECTED_PHP_DIR') . DIRECTORY_SEPARATOR . '5.5.17-apxs-patch';
     $this->assertFileEquals($sourceExpectedDirectory . '/Makefile.global', $sourceDirectory . '/Makefile.global');
     $this->assertFileEquals($sourceExpectedDirectory . '/configure', $sourceDirectory . '/configure');
 }
コード例 #11
0
 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');
     }
 }
コード例 #12
0
ファイル: Extension.php プロジェクト: bensb/phpbrew
 public function buildMetaFromName($name)
 {
     $path = Config::getBuildDir() . '/' . Config::getCurrentPhpName() . '/ext/' . $name;
     $xml = $path . '/package.xml';
     $m4 = $path . '/config.m4';
     if (file_exists($xml)) {
         $this->logger->warning("===> Using xml extension meta");
         $meta = new ExtensionMetaXml($xml);
     } elseif (file_exists($m4)) {
         $this->logger->warning("===> Using m4 extension meta");
         $meta = new ExtensionMetaM4($m4);
     } else {
         $this->logger->warning("===> Using polyfill extension meta");
         $meta = new ExtensionMetaPolyfill($name);
     }
     return $meta;
 }
コード例 #13
0
 /**
  * This method is the top logic of an application. when there is no
  * argument provided, we show help content by default.
  *
  * @return bool return true if success
  */
 public function execute()
 {
     $options = $this->getOptions();
     if ($options->version) {
         $this->logger->writeln($this->getName() . ' - ' . $this->getVersion());
         $this->logger->writeln("cliframework core: " . $this->getCoreVersion());
         return true;
     }
     $arguments = func_get_args();
     // show list and help by default
     $help = $this->getCommand('help');
     $help->setOptions($options);
     if ($help || $options->help) {
         $help->executeWrapper($arguments);
         return true;
     }
     throw new CommandNotFoundException($this, 'help');
 }
コード例 #14
0
ファイル: SchemaUtils.php プロジェクト: appleboy/LazyRecord
 /**
  * Returns schema objects
  *
  * @return array schema objects
  */
 public static function findSchemasByArguments(ConfigLoader $loader, array $args, Logger $logger = null)
 {
     if (count($args) && !file_exists($args[0])) {
         $classes = array();
         // it's classnames
         foreach ($args as $class) {
             // call class loader to load
             if (class_exists($class, true)) {
                 $classes[] = $class;
             } else {
                 if ($logger) {
                     $logger->warn("{$class} not found.");
                 } else {
                     echo ">>> {$class} not found.\n";
                 }
             }
         }
         return ClassUtils::schema_classes_to_objects(array_unique($classes));
     } else {
         $finder = new SchemaFinder();
         if (count($args) && file_exists($args[0])) {
             $finder->setPaths($args);
             foreach ($args as $file) {
                 if (is_file($file)) {
                     require_once $file;
                 }
             }
         } else {
             if ($paths = $loader->getSchemaPaths()) {
                 $finder->setPaths($paths);
             }
         }
         $finder->find();
         // load class from class map
         if ($classMap = $loader->getClassMap()) {
             foreach ($classMap as $file => $class) {
                 if (!is_integer($file) && is_string($file)) {
                     require $file;
                 }
             }
         }
         return SchemaLoader::loadDeclaredSchemas();
     }
 }
コード例 #15
0
 public function createSchemaGenerator()
 {
     $g = new \LazyRecord\Schema\SchemaGenerator(ConfigLoader::getInstance(), Logger::getInstance());
     $g->forceUpdate = true;
     return $g;
 }
コード例 #16
0
 public function setUp()
 {
     $logger = new Logger();
     $logger->setQuiet();
     $this->manager = new ExtensionManager($logger);
 }
コード例 #17
0
ファイル: ReleaseList.php プロジェクト: phpbrew/phpbrew
 private static function downloadReleaseListFromOfficialSite($version, OptionResult $options = null)
 {
     $max = $options && $options->old ? 1000 : 100;
     $url = "https://secure.php.net/releases/index.php?json&version={$version}&max={$max}";
     $file = DownloadFactory::getInstance(Logger::getInstance(), $options)->download($url);
     $json = file_get_contents($file);
     return json_decode($json, true);
 }
コード例 #18
0
ファイル: MakeTaskTest.php プロジェクト: phpbrew/phpbrew
 public function createLogger()
 {
     $logger = new Logger();
     $logger->setQuiet();
     return $logger;
 }
コード例 #19
0
ファイル: RegExpPatchRule.php プロジェクト: phpbrew/phpbrew
 public function apply(Buildable $build, Logger $logger)
 {
     $patched = 0;
     foreach ($this->files as $file) {
         $path = $build->getSourceDirectory() . DIRECTORY_SEPARATOR . $file;
         if (!file_exists($path)) {
             $logger->error("file {$path} doesn't exist in the build directory.");
             continue;
         }
         if ($content = file_get_contents($path)) {
             $content = $this->applyTextContent($content, $patched);
             if (false === file_put_contents($path, $content)) {
                 $logger->error("Patch on {$path} write failed.");
             }
         }
     }
     return $patched;
 }
コード例 #20
0
ファイル: Utils.php プロジェクト: phpbrew/phpbrew
 public static function recursive_unlink($path, Logger $logger)
 {
     $directoryIterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
     $it = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($it as $file) {
         $logger->debug('Deleting ' . $file->getPathname());
         if ($file->isDir()) {
             rmdir($file->getPathname());
         } else {
             unlink($file->getPathname());
         }
     }
     if (is_dir($path)) {
         rmdir($path);
     } elseif (is_file($path)) {
         unlink($path);
     }
 }
コード例 #21
0
ファイル: DownloaderTest.php プロジェクト: phpbrew/phpbrew
 public function setUp()
 {
     $this->logger = Logger::getInstance();
     $this->logger->setQuiet();
 }
コード例 #22
0
ファイル: bootstrap.php プロジェクト: appleboy/LazyRecord
<?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...");