From 7a33aa1e2bfc1570043a2cc3048cedd79b1ec47b Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 13 Apr 2016 15:10:25 +0100 Subject: [PATCH] removed lots of dependancies to reduce the chance of conflicts --- composer.json | 5 +- composer.lock | 240 +----------------------------------------- src/Loggable.php | 23 ++++ src/VerifyCommand.php | 35 +++--- 4 files changed, 41 insertions(+), 262 deletions(-) create mode 100644 src/Loggable.php diff --git a/composer.json b/composer.json index 6c7cca0..497b967 100644 --- a/composer.json +++ b/composer.json @@ -9,10 +9,7 @@ ], "require": { "silktide/syringe": "^1.1", - "symfony/console": "^3.0", - "monolog/monolog": "^1.19", - "symfony/monolog-bridge": "^3.0", - "symfony/event-dispatcher": "^3.0" + "symfony/console": "~2.8|^3.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 9a45e4e..80ae1de 100644 --- a/composer.lock +++ b/composer.lock @@ -4,87 +4,9 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "0ee70ab96167afb688e12c51ac5a4f3c", - "content-hash": "f2d6d060c62e55e551446b3ce707cee0", + "hash": "f86cae4e768cc4deeb0d4e44c491526b", + "content-hash": "b158444a96165ed8010ddf0ed6fa7fca", "packages": [ - { - "name": "monolog/monolog", - "version": "1.19.0", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "5f56ed5212dc509c8dc8caeba2715732abb32dbf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5f56ed5212dc509c8dc8caeba2715732abb32dbf", - "reference": "5f56ed5212dc509c8dc8caeba2715732abb32dbf", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0" - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "^2.4.9", - "doctrine/couchdb": "~1.0@dev", - "graylog2/gelf-php": "~1.0", - "jakub-onderka/php-parallel-lint": "0.9", - "php-amqplib/php-amqplib": "~2.4", - "php-console/php-console": "^3.1.3", - "phpunit/phpunit": "~4.5", - "phpunit/phpunit-mock-objects": "2.3.0", - "raven/raven": "^0.13", - "ruflin/elastica": ">=0.90 <3.0", - "swiftmailer/swiftmailer": "~5.3" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-mongo": "Allow sending log messages to a MongoDB server", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "php-console/php-console": "Allow sending log messages to Google Chrome", - "raven/raven": "Allow sending log messages to a Sentry server", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "http://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ], - "time": "2016-04-12 18:29:35" - }, { "name": "pimple/pimple", "version": "v3.0.2", @@ -131,44 +53,6 @@ ], "time": "2015-09-11 15:10:35" }, - { - "name": "psr/log", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-0": { - "Psr\\Log\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2012-12-21 11:40:51" - }, { "name": "silktide/syringe", "version": "1.1.12", @@ -271,126 +155,6 @@ "homepage": "https://symfony.com", "time": "2016-03-16 17:00:50" }, - { - "name": "symfony/event-dispatcher", - "version": "v3.0.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "9002dcf018d884d294b1ef20a6f968efc1128f39" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9002dcf018d884d294b1ef20a6f968efc1128f39", - "reference": "9002dcf018d884d294b1ef20a6f968efc1128f39", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2016-03-10 10:34:12" - }, - { - "name": "symfony/monolog-bridge", - "version": "v3.0.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/monolog-bridge.git", - "reference": "017a712b6f2fcbe5c1389ed5fd1215c935dadb17" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/monolog-bridge/zipball/017a712b6f2fcbe5c1389ed5fd1215c935dadb17", - "reference": "017a712b6f2fcbe5c1389ed5fd1215c935dadb17", - "shasum": "" - }, - "require": { - "monolog/monolog": "~1.11", - "php": ">=5.5.9" - }, - "require-dev": { - "symfony/console": "~2.8|~3.0", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0" - }, - "suggest": { - "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings. You need version ~2.3 of the console for it.", - "symfony/event-dispatcher": "Needed when using log messages in console commands.", - "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel." - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\Monolog\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Monolog Bridge", - "homepage": "https://symfony.com", - "time": "2016-03-04 07:55:57" - }, { "name": "symfony/polyfill-mbstring", "version": "v1.1.1", diff --git a/src/Loggable.php b/src/Loggable.php new file mode 100644 index 0000000..7c500b8 --- /dev/null +++ b/src/Loggable.php @@ -0,0 +1,23 @@ +log($message, "\033[32m"); + } + + public function log($message, $color="") + { + echo $color.$message."\033[0m\n"; + } + + public function error($message) + { + $this->log($message, "\033[31m"); + } +} \ No newline at end of file diff --git a/src/VerifyCommand.php b/src/VerifyCommand.php index 3ec7014..ff8adf7 100644 --- a/src/VerifyCommand.php +++ b/src/VerifyCommand.php @@ -2,27 +2,21 @@ namespace Silktide\SyringeVerifier; -use Downsider\PuzzleDI\Helper\PuzzleDataCollector; -use Monolog\Logger; -use Psr\Log\LoggerTrait; -use Psr\Log\LogLevel; use Silktide\Syringe\ContainerBuilder; use Silktide\Syringe\Loader\JsonLoader; use Silktide\Syringe\Loader\YamlLoader; use Silktide\Syringe\ReferenceResolver; -use Silktide\Syringe\SyringeServiceProvider; use Silktide\SyringeVerifier\Parser\ComposerParser; use Silktide\SyringeVerifier\Parser\ComposerParserResult; -use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class VerifyCommand extends Command { + use Loggable; + protected $composerParser; protected $log; protected $input; @@ -32,7 +26,6 @@ public function __construct() { parent::__construct(); $this->composerParser = new ComposerParser(); - $this->log = new Logger("SyringeVerifier"); } public function configure() @@ -48,8 +41,6 @@ public function execute(InputInterface $inputInterface, OutputInterface $outputI $this->input = $inputInterface; $this->output = $outputInterface; - $this->log->setHandlers([new ConsoleHandler($outputInterface, null, [LogLevel::DEBUG])]); - // 1. Work out what directory we're caring about $directory = getcwd(); // That was easy @@ -58,31 +49,32 @@ public function execute(InputInterface $inputInterface, OutputInterface $outputI $parserResult = $this->composerParser->parse($directory."/composer.json"); if (!$parserResult->usesSyringe() && !$inputInterface->getOption("force")) { - $this->log->critical("The project in this directory '{$directory}' is not a library includable by syringe via Puzzle-DI"); + $this->error("The project in this directory '{$directory}' is not a library includable by syringe via Puzzle-DI"); return 1; } $container = $this->setupContainer($parserResult); - $this->log->info("Attempting to build all services!"); + $this->log("Attempting to build all services!"); + $this->log(count($container->keys())." services/parameters found!"); + /** @var \Exception[] $exceptions */ $exceptions = []; foreach ($container->keys() as $key) { try{ $build = $container[$key]; } catch (\Exception $e) { - $exceptions[] = [$e->getMessage(), $e->getFile(), $e->getLine()]; + $exceptions[] = $e; } } if (count($exceptions) > 0) { - $this->log->crit("Failed to successfully build ".count($exceptions)." bits of DI config"); - $table = new Table($outputInterface); - $table->setHeaders(["Message", "File", "Line"]); - $table->setRows($exceptions); - $table->render(); + $this->error("Failed to successfully build ".count($exceptions)." bits of DI config"); + foreach ($exceptions as $e) { + $this->log(" Message:".$e->getMessage().". File: ".$e->getFile().". Line: ".$e->getLine()); + } return 1; } else { - $this->log->info("Succeeded!"); + $this->success("Succeeded!"); return 0; } } @@ -114,6 +106,9 @@ public function setupContainer(ComposerParserResult $parserResult) } $additionalConfigs = $this->input->getOption("configs"); + foreach ($additionalConfigs as $config) { + $builder->addConfigFile(realpath($config)); + } $builder->addConfigFiles($parserResult->getConfigList());