From 57774b225cbfa789e51849791a634d1cfe20002a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bj=C3=B8rnskov?= Date: Fri, 10 Oct 2014 10:39:56 +0200 Subject: [PATCH 01/14] Require Pimple 3.0 instead of whole of Silex --- composer.json | 10 ++++---- src/Igorw/Silex/ConfigServiceProvider.php | 10 ++++---- .../integration/ConfigServiceProviderTest.php | 24 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/composer.json b/composer.json index a20436a..c7716e4 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "igorw/config-service-provider", - "description": "A config ServiceProvider for Silex with support for php, json and yaml.", - "keywords": ["silex"], + "description": "A config ServiceProvider for Pimple with support for php, json and yaml.", + "keywords": ["silex", "pimple"], "license": "MIT", "authors": [ { @@ -14,7 +14,7 @@ } ], "require": { - "silex/silex": "~1.0" + "pimple/pimple": "~3.0" }, "require-dev": { "symfony/yaml": "~2.1", @@ -25,11 +25,11 @@ "jamesmoss/toml": "~0.1" }, "autoload": { - "psr-0": { "Igorw\\Silex": "src" } + "psr-4": { "Igorw\\Silex\\": "src/Igorw/Silex/" } }, "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "2.0-dev" } } } diff --git a/src/Igorw/Silex/ConfigServiceProvider.php b/src/Igorw/Silex/ConfigServiceProvider.php index ee70599..e77ca70 100644 --- a/src/Igorw/Silex/ConfigServiceProvider.php +++ b/src/Igorw/Silex/ConfigServiceProvider.php @@ -11,8 +11,8 @@ namespace Igorw\Silex; -use Silex\Application; -use Silex\ServiceProviderInterface; +use Pimple\Container; +use Pimple\ServiceProviderInterface; class ConfigServiceProvider implements ServiceProviderInterface { @@ -40,7 +40,7 @@ public function __construct($filename, array $replacements = array(), ConfigDriv )); } - public function register(Application $app) + public function register(Container $app) { $config = $this->readConfig(); @@ -51,11 +51,11 @@ public function register(Application $app) $this->merge($app, $config); } - public function boot(Application $app) + public function boot(Container $app) { } - private function merge(Application $app, array $config) + private function merge(Container $app, array $config) { if ($this->prefix) { $config = array($this->prefix => $config); diff --git a/tests/integration/ConfigServiceProviderTest.php b/tests/integration/ConfigServiceProviderTest.php index 168b721..f98bfdc 100644 --- a/tests/integration/ConfigServiceProviderTest.php +++ b/tests/integration/ConfigServiceProviderTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Silex\Application; +use Pimple\Container; use Igorw\Silex\ConfigServiceProvider; /** @@ -23,7 +23,7 @@ class ConfigServiceProviderTest extends \PHPUnit_Framework_TestCase */ public function testRegisterWithoutReplacement($filename) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filename)); @@ -36,7 +36,7 @@ public function testRegisterWithoutReplacement($filename) */ public function testRegisterWithReplacement($filename) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filename, array( 'data' => 'test-replacement' @@ -65,7 +65,7 @@ public function testEmptyConfigs($filename) */ public function testInFileReplacements($filename) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filename)); @@ -81,7 +81,7 @@ public function testInFileReplacements($filename) */ public function testTomlMergeConfigs() { - $app = new Application(); + $app = new Container(); $filenameBase = __DIR__."/Fixtures/config_base.toml"; $filenameExtended = __DIR__."/Fixtures/config_extend.toml"; @@ -110,7 +110,7 @@ public function testTomlMergeConfigs() */ public function testConfigWithPrefix($filename) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filename, array(), null, 'prefix')); $this->assertNotNull($app['prefix']); $this->assertSame(true, $app['prefix']['debug']); @@ -122,7 +122,7 @@ public function testConfigWithPrefix($filename) */ public function testMergeConfigsWithPrefix($filenameBase, $filenameExtended) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filenameBase, array(), null, 'prefix')); $app->register(new ConfigServiceProvider($filenameExtended, array(), null, 'prefix')); @@ -143,7 +143,7 @@ public function testMergeConfigsWithPrefix($filenameBase, $filenameExtended) */ public function testConfigsWithMultiplePrefixes($filenameBase, $filenameExtended) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filenameBase, array(), null, 'base')); $app->register(new ConfigServiceProvider($filenameExtended, array(), null, 'extended')); @@ -160,7 +160,7 @@ public function testConfigsWithMultiplePrefixes($filenameBase, $filenameExtended */ public function testMergeConfigs($filenameBase, $filenameExtended) { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider($filenameBase)); $app->register(new ConfigServiceProvider($filenameExtended)); @@ -189,7 +189,7 @@ public function testMergeConfigs($filenameBase, $filenameExtended) */ public function invalidJsonShouldThrowException() { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider(__DIR__."/Fixtures/broken.json")); } @@ -199,7 +199,7 @@ public function invalidJsonShouldThrowException() */ public function invalidYamlShouldThrowException() { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider(__DIR__."/Fixtures/broken.yml")); } @@ -209,7 +209,7 @@ public function invalidYamlShouldThrowException() */ public function invalidTomlShouldThrowException() { - $app = new Application(); + $app = new Container(); $app->register(new ConfigServiceProvider(__DIR__."/Fixtures/broken.toml")); } From f5d1f1afa1793e94432833757ddc0091979a45ad Mon Sep 17 00:00:00 2001 From: Ludovic Fleury Date: Wed, 4 Feb 2015 05:05:50 +0100 Subject: [PATCH 02/14] Update the Yaml driver As mentioned in the [symfony\yaml](https://github.com/symfony/Yaml/commit/a43656845f677a0f308f97667b2789410b67dc36) "Passing a file as an input is a deprecated feature and will be removed in 3.0." --- src/Igorw/Silex/YamlConfigDriver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Igorw/Silex/YamlConfigDriver.php b/src/Igorw/Silex/YamlConfigDriver.php index 5b849a9..8a36b51 100644 --- a/src/Igorw/Silex/YamlConfigDriver.php +++ b/src/Igorw/Silex/YamlConfigDriver.php @@ -11,7 +11,9 @@ public function load($filename) if (!class_exists('Symfony\\Component\\Yaml\\Yaml')) { throw new \RuntimeException('Unable to read yaml as the Symfony Yaml Component is not installed.'); } - $config = Yaml::parse($filename); + + $input = file_get_contents($filename); + $config = Yaml::parse($input); return $config ?: array(); } From c68da8cbf57391bac72d5bb21157bc1448bd3a38 Mon Sep 17 00:00:00 2001 From: Ludovic Fleury Date: Wed, 4 Feb 2015 05:08:31 +0100 Subject: [PATCH 03/14] Update symfony/yaml dependency requirement --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a20436a..69a3bb9 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,11 @@ "silex/silex": "~1.0" }, "require-dev": { - "symfony/yaml": "~2.1", + "symfony/yaml": "~2.2", "jamesmoss/toml": "~0.1" }, "suggest": { - "symfony/yaml": "~2.1", + "symfony/yaml": "~2.2", "jamesmoss/toml": "~0.1" }, "autoload": { From 5bd36be61e67d8f63342afa3108d654d7240e57b Mon Sep 17 00:00:00 2001 From: Ludovic Fleury Date: Wed, 4 Feb 2015 05:11:36 +0100 Subject: [PATCH 04/14] Update the symfony/yaml version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1950a9a..c8c0585 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ To use Yaml instead of JSON, just pass a file that ends on `.yml`: $app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__."/../config/services.yml")); -Note, you will have to require the `~2.1` of the `symfony/yaml` package. +Note, you will have to require the `~2.2` of the `symfony/yaml` package. ### Using TOML From f849e6e5a2aca2351ab3ca35c3a9ef1e2b0c8825 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Fri, 5 Jun 2015 19:36:14 +0000 Subject: [PATCH 05/14] prepare to use the fork --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a61688d..f07bed5 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "igorw/config-service-provider", + "name": "saxulum/config-service-provider", "description": "A config ServiceProvider for Pimple with support for php, json and yaml.", "keywords": ["silex", "pimple"], "license": "MIT", @@ -27,6 +27,9 @@ "autoload": { "psr-4": { "Igorw\\Silex\\": "src/Igorw/Silex/" } }, + "replace": { + "igorw/config-service-provider": "self.version" + }, "extra": { "branch-alias": { "dev-master": "2.0-dev" From 5355969e7f33a4c2d84d4a84dd4c7edb8db9834d Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sun, 9 Aug 2015 09:37:59 +0200 Subject: [PATCH 06/14] add phpunit --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index f07bed5..ce8ae48 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "pimple/pimple": "~3.0" }, "require-dev": { + "phpunit/phpunit": "4.0.*", "symfony/yaml": "~2.2", "jamesmoss/toml": "~0.1" }, From 695db2da523ffada216409405809cb93e05c5bf9 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sun, 9 Aug 2015 09:38:15 +0200 Subject: [PATCH 07/14] allow empty json => [] --- src/Igorw/Silex/JsonConfigDriver.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Igorw/Silex/JsonConfigDriver.php b/src/Igorw/Silex/JsonConfigDriver.php index c9c8680..566d707 100644 --- a/src/Igorw/Silex/JsonConfigDriver.php +++ b/src/Igorw/Silex/JsonConfigDriver.php @@ -25,6 +25,12 @@ public function supports($filename) private function parseJson($filename) { $json = file_get_contents($filename); + + // handle empty as [] + if(empty($json)) { + return array(); + } + return json_decode($json, true); } From 3808058e0a498a1a0ee55207352fca1fe414302a Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sun, 9 Aug 2015 09:42:06 +0200 Subject: [PATCH 08/14] add links to packageist, travis... --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c8c0585..a558270 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # ConfigServiceProvider +[![Build Status](https://api.travis-ci.org/saxulum/ConfigServiceProvider.png?branch=master)](https://travis-ci.org/saxulum/ConfigServiceProvider) +[![Total Downloads](https://poser.pugx.org/saxulum/ConfigServiceProvider/downloads.png)](https://packagist.org/packages/saxulum/ConfigServiceProvider) +[![Latest Stable Version](https://poser.pugx.org/saxulum/ConfigServiceProvider/v/stable.png)](https://packagist.org/packages/saxulum/ConfigServiceProvider) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/saxulum/ConfigServiceProvider/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/saxulum/ConfigServiceProvider/?branch=master) + A config ServiceProvider for [Silex](http://silex.sensiolabs.org) with support for php, json, yaml, and toml. From 1a8ee045d2383e9ce560c22e2ad2f73d5e292de7 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sun, 9 Aug 2015 07:47:26 +0000 Subject: [PATCH 09/14] fix badge links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a558270..4565e09 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # ConfigServiceProvider [![Build Status](https://api.travis-ci.org/saxulum/ConfigServiceProvider.png?branch=master)](https://travis-ci.org/saxulum/ConfigServiceProvider) -[![Total Downloads](https://poser.pugx.org/saxulum/ConfigServiceProvider/downloads.png)](https://packagist.org/packages/saxulum/ConfigServiceProvider) -[![Latest Stable Version](https://poser.pugx.org/saxulum/ConfigServiceProvider/v/stable.png)](https://packagist.org/packages/saxulum/ConfigServiceProvider) +[![Total Downloads](https://poser.pugx.org/saxulum/config-service-provider/downloads.png)](https://packagist.org/packages/saxulum/config-service-provider) +[![Latest Stable Version](https://poser.pugx.org/saxulum/config-service-provider/v/stable.png)](https://packagist.org/packages/saxulum/config-service-provider) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/saxulum/ConfigServiceProvider/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/saxulum/ConfigServiceProvider/?branch=master) A config ServiceProvider for [Silex](http://silex.sensiolabs.org) with support From 1ce224d23393c383caf0c9e5b436cc3a8c3bdeeb Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sat, 28 Nov 2015 14:25:25 +0100 Subject: [PATCH 10/14] check against php7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f6595d5..95224c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm before_script: From 0cfa94cce8823ecfccf4889b6c202dd72a91d177 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sat, 28 Nov 2015 14:25:56 +0100 Subject: [PATCH 11/14] update phpversion --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index ce8ae48..4bf870e 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ } ], "require": { + "php": ">=5.3.3,<8.0", "pimple/pimple": "~3.0" }, "require-dev": { From 2cc62d33d20f7b63c9868075bd7a601636557969 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Tue, 1 Dec 2015 13:00:40 +0100 Subject: [PATCH 12/14] allow symfony 3 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4bf870e..ae85b3e 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,11 @@ }, "require-dev": { "phpunit/phpunit": "4.0.*", - "symfony/yaml": "~2.2", + "symfony/yaml": "~2.2|~3.0", "jamesmoss/toml": "~0.1" }, "suggest": { - "symfony/yaml": "~2.2", + "symfony/yaml": "~2.2|~3.0", "jamesmoss/toml": "~0.1" }, "autoload": { From e165db5b248c7160ed5b812c43aee7548cb2dd02 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Tue, 11 Oct 2016 10:39:55 +0200 Subject: [PATCH 13/14] remove php 5.3.3 from testing --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 95224c6..0ea1df4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.3.3 - 5.3 - 5.4 - 5.5 From 93f69431ed8880d1cef9f17215549309f9f3b813 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Fri, 20 Apr 2018 19:18:14 +0200 Subject: [PATCH 14/14] add "abandoned": true --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ae85b3e..0a6ab47 100644 --- a/composer.json +++ b/composer.json @@ -36,5 +36,6 @@ "branch-alias": { "dev-master": "2.0-dev" } - } + }, + "abandoned": true }