├── .gitignore ├── .php_cs ├── .scrutinizer.yml ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml.dist ├── src ├── Config │ ├── DBlibConfig.php │ ├── MySqlConfig.php │ ├── OracleConfig.php │ ├── PdoConfig.php │ ├── PdoConfigFactory.php │ ├── PdoConfigInterface.php │ ├── PgSqlConfig.php │ ├── SqlSrvConfig.php │ └── SqliteConfig.php └── Provider │ └── PDOServiceProvider.php └── tests ├── Config ├── DBlibConfigTest.php ├── MySqlConfigTest.php ├── OracleConfigTest.php ├── PdoConfigFactoryTest.php ├── PgSqlConfigTest.php ├── SqlSrvConfigTest.php └── SqliteConfigTest.php └── Provider └── PDOServiceProviderTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | .git 2 | .svn 3 | _svn 4 | .CVS 5 | .arch-params 6 | .bzr 7 | _darcs 8 | .hg 9 | .monotone 10 | .svn 11 | _svn 12 | __MACOSX 13 | .settings 14 | .buildpath 15 | .project 16 | .cache 17 | .netbeans 18 | catalog.xml 19 | *.psd 20 | *~ 21 | /bin 22 | /build 23 | /vendor 24 | composer.phar 25 | phpunit.xml 26 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | exclude(array( 5 | 'vendor', 6 | 'cache', 7 | 'logs', 8 | )) 9 | ->notName('/.*\.(ico|gif|png|jpeg|jpg|bmp|tiff|mp3|wma|wmv|avi|flv|swf|zip|bz2|gz|tar|7z|lzma|doc|docx|csv|xls|xlsx|ppt|pptx|odt|log|phar|jar)/') 10 | ->in(__DIR__.'/src') 11 | ; 12 | 13 | return Symfony\CS\Config\Config::create() 14 | ->fixers(array( 15 | 'indentation', 16 | 'linefeed', 17 | 'trailing_spaces', 18 | 'unused_use', 19 | 'phpdoc_params', 20 | 'visibility', 21 | 'return', 22 | 'short_tag', 23 | 'braces', 24 | 'include', 25 | 'php_closing_tag', 26 | 'extra_empty_lines', 27 | //'psr0', 28 | 'controls_spaces', 29 | 'elseif', 30 | 'eof_ending', 31 | )) 32 | ->finder($finder) 33 | ; 34 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - php 3 | 4 | tools: 5 | external_code_coverage: 6 | timeout: 600 7 | php_mess_detector: true 8 | php_cpd: true 9 | php_code_sniffer: 10 | config: 11 | standard: PSR2 12 | php_pdepend: true 13 | php_analyzer: true 14 | sensiolabs_security_checker: true 15 | 16 | 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | sudo: false 4 | 5 | php: 6 | - 5.3 7 | - 5.4 8 | - 5.5 9 | - 5.6 10 | - hhvm 11 | - 7.0 12 | 13 | matrix: 14 | allow_failures: 15 | - php: hhvm 16 | - php: 7.0 17 | 18 | before_script: 19 | - curl -s http://getcomposer.org/installer | php 20 | - php composer.phar install --dev --no-interaction 21 | 22 | script: 23 | - mkdir -p build/logs 24 | - php vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml 25 | 26 | after_script: 27 | - wget https://scrutinizer-ci.com/ocular.phar 28 | - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Charles Sanquer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PdoServiceProvider 2 | ================== 3 | 4 | **LOOKING FOR NEW MAINTAINER** 5 | 6 | [![Latest Stable Version](https://poser.pugx.org/csanquer/pdo-service-provider/v/stable.svg)](https://packagist.org/packages/csanquer/pdo-service-provider) 7 | [![Latest Unstable Version](https://poser.pugx.org/csanquer/pdo-service-provider/v/unstable.svg)](https://packagist.org/packages/csanquer/pdo-service-provider) 8 | [![Build Status](https://travis-ci.org/csanquer/PdoServiceProvider.png?branch=master)](https://travis-ci.org/csanquer/PdoServiceProvider) 9 | [![Code Coverage](https://scrutinizer-ci.com/g/csanquer/PdoServiceProvider/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/csanquer/PdoServiceProvider/?branch=master) 10 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/csanquer/PdoServiceProvider/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/csanquer/PdoServiceProvider/?branch=master) 11 | [![SensioLabsInsight](https://insight.sensiolabs.com/projects/e29001fc-fd0c-4fb8-8995-592deb17c991/mini.png)](https://insight.sensiolabs.com/projects/e29001fc-fd0c-4fb8-8995-592deb17c991) 12 | 13 | [![Maintenance](https://img.shields.io/maintenance/yes/2015.svg)]() 14 | [![License](https://poser.pugx.org/csanquer/pdo-service-provider/license.svg)](https://packagist.org/packages/csanquer/pdo-service-provider) 15 | [![Daily Downloads](https://poser.pugx.org/csanquer/pdo-service-provider/d/daily.png)](https://packagist.org/packages/csanquer/pdo-service-provider) 16 | [![Monthly Downloads](https://poser.pugx.org/csanquer/pdo-service-provider/d/monthly.png)](https://packagist.org/packages/csanquer/pdo-service-provider) 17 | [![Total Downloads](https://poser.pugx.org/csanquer/pdo-service-provider/downloads.svg)](https://packagist.org/packages/csanquer/pdo-service-provider) 18 | 19 | 20 | a Simple PDO service provider for Silex 21 | 22 | Installation 23 | ------------ 24 | 25 | add this package to [Composer](https://getcomposer.org/) dependencies configuration: 26 | 27 | ```sh 28 | php composer.phar require "csanquer/pdo-service-provider=~1.0" 29 | ``` 30 | 31 | Usage 32 | ----- 33 | 34 | * Configure only one database 35 | 36 | use the `PdoServiceProvider` silex provider : 37 | 38 | ```php 39 | use Csanquer\Silex\PdoServiceProvider\Provider\PDOServiceProvider; 40 | use Silex\Application; 41 | 42 | $app = new Application(); 43 | $app->register( 44 | // you can customize services and options prefix with the provider first argument (default = 'pdo') 45 | new PDOServiceProvider('pdo'), 46 | array( 47 | 'pdo.server' => array( 48 | // PDO driver to use among : mysql, pgsql , oracle, mssql, sqlite, dblib 49 | 'driver' => 'mysql', 50 | 'host' => 'mysql', 51 | 'dbname' => 'rfactori', 52 | 'port' => 3306, 53 | 'user' => 'ger', 54 | 'password' => 'GER', 55 | ), 56 | // optional PDO attributes used in PDO constructor 4th argument driver_options 57 | // some PDO attributes can be used only as PDO driver_options 58 | // see http://www.php.net/manual/fr/pdo.construct.php 59 | 'pdo.options' => array( 60 | \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" 61 | ), 62 | // optional PDO attributes set with PDO::setAttribute 63 | // see http://www.php.net/manual/fr/pdo.setattribute.php 64 | 'pdo.attributes' => array( 65 | \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, 66 | ), 67 | ) 68 | ); 69 | 70 | // get PDO connection 71 | $pdo = $app['pdo']; 72 | ``` 73 | 74 | * Configure several databases 75 | 76 | ```php 77 | use Csanquer\Silex\PdoServiceProvider\Provider\PdoServiceProvider; 78 | use Silex\Application; 79 | 80 | $app = new Application(); 81 | $app->register( 82 | // use custom prefix for service and options 83 | // first PDO connection 84 | new PdoServiceProvider('pdo.db1'), 85 | array( 86 | // use previous custom prefix pdo.db1 87 | 'pdo.db1.server' => array( 88 | // PDO driver to use among : mysql, pgsql , oracle, mssql, sqlite, dblib 89 | 'driver' => 'mysql', 90 | 'host' => '127.0.0.1', 91 | 'dbname' => 'db1', 92 | 'port' => 3306, 93 | 'user' => 'username', 94 | 'password' => 'password', 95 | ), 96 | // optional PDO attributes used in PDO constructor 4th argument driver_options 97 | 'pdo.db1.options' => array( 98 | \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" 99 | ), 100 | // optional PDO attributes set with PDO::setAttribute 101 | 'pdo.db1.attributes' => array( 102 | \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, 103 | ), 104 | ) 105 | ); 106 | 107 | $app->register( 108 | // second PDO connection 109 | new PdoServiceProvider('pdo.db2'), 110 | array( 111 | 'pdo.db2.server' => array( 112 | 'driver' => 'sqlite', 113 | 'path' => 'var/db/db2.sqlite', 114 | ), 115 | ) 116 | ); 117 | 118 | // get PDO connections 119 | $db1Pdo = $app['pdo.db1']; 120 | $db2Pdo = $app['pdo.db2']; 121 | ``` 122 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "csanquer/pdo-service-provider", 3 | "description": "a PDO database service provider for silex", 4 | "keywords": [ 5 | "silex", "database", "pdo", "service provider" 6 | ], 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Charles Sanquer", 11 | "email": "charles.sanquer@gmail.com" 12 | } 13 | ], 14 | "minimum-stability": "dev", 15 | "prefer-stable": true, 16 | "require": { 17 | "silex/silex": "~1.3", 18 | "symfony/options-resolver": "~2.7" 19 | }, 20 | "require-dev": { 21 | "phpunit/phpunit": "~4.8" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "Csanquer\\Silex\\PdoServiceProvider\\": "src/" 26 | } 27 | }, 28 | "autoload-dev": { 29 | "psr-4": { 30 | "Csanquer\\Silex\\PdoServiceProvider\\Tests\\": "tests/" 31 | } 32 | }, 33 | "extra": { 34 | "branch-alias": { 35 | "dev-master": "1.1.x-dev" 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "7a700d81c0b69c74825292298dbed177", 8 | "content-hash": "35e574dfc7ef3b9ebd5450ab9bb69296", 9 | "packages": [ 10 | { 11 | "name": "pimple/pimple", 12 | "version": "v1.1.1", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/silexphp/Pimple.git", 16 | "reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/silexphp/Pimple/zipball/2019c145fe393923f3441b23f29bbdfaa5c58c4d", 21 | "reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": ">=5.3.0" 26 | }, 27 | "type": "library", 28 | "extra": { 29 | "branch-alias": { 30 | "dev-master": "1.1.x-dev" 31 | } 32 | }, 33 | "autoload": { 34 | "psr-0": { 35 | "Pimple": "lib/" 36 | } 37 | }, 38 | "notification-url": "https://packagist.org/downloads/", 39 | "license": [ 40 | "MIT" 41 | ], 42 | "authors": [ 43 | { 44 | "name": "Fabien Potencier", 45 | "email": "fabien@symfony.com" 46 | } 47 | ], 48 | "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", 49 | "homepage": "http://pimple.sensiolabs.org", 50 | "keywords": [ 51 | "container", 52 | "dependency injection" 53 | ], 54 | "time": "2013-11-22 08:30:29" 55 | }, 56 | { 57 | "name": "psr/log", 58 | "version": "1.0.0", 59 | "source": { 60 | "type": "git", 61 | "url": "https://github.com/php-fig/log.git", 62 | "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" 63 | }, 64 | "dist": { 65 | "type": "zip", 66 | "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", 67 | "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", 68 | "shasum": "" 69 | }, 70 | "type": "library", 71 | "autoload": { 72 | "psr-0": { 73 | "Psr\\Log\\": "" 74 | } 75 | }, 76 | "notification-url": "https://packagist.org/downloads/", 77 | "license": [ 78 | "MIT" 79 | ], 80 | "authors": [ 81 | { 82 | "name": "PHP-FIG", 83 | "homepage": "http://www.php-fig.org/" 84 | } 85 | ], 86 | "description": "Common interface for logging libraries", 87 | "keywords": [ 88 | "log", 89 | "psr", 90 | "psr-3" 91 | ], 92 | "time": "2012-12-21 11:40:51" 93 | }, 94 | { 95 | "name": "silex/silex", 96 | "version": "v1.3.4", 97 | "source": { 98 | "type": "git", 99 | "url": "https://github.com/silexphp/Silex.git", 100 | "reference": "d6de62716fcda76084f3015165125f30b1563517" 101 | }, 102 | "dist": { 103 | "type": "zip", 104 | "url": "https://api.github.com/repos/silexphp/Silex/zipball/d6de62716fcda76084f3015165125f30b1563517", 105 | "reference": "d6de62716fcda76084f3015165125f30b1563517", 106 | "shasum": "" 107 | }, 108 | "require": { 109 | "php": ">=5.3.9", 110 | "pimple/pimple": "~1.0", 111 | "symfony/event-dispatcher": "~2.3|3.0.*", 112 | "symfony/http-foundation": "~2.3|3.0.*", 113 | "symfony/http-kernel": "~2.3|3.0.*", 114 | "symfony/routing": "~2.3|3.0.*" 115 | }, 116 | "require-dev": { 117 | "doctrine/dbal": "~2.2", 118 | "monolog/monolog": "^1.4.1", 119 | "swiftmailer/swiftmailer": "~5", 120 | "symfony/browser-kit": "~2.3|3.0.*", 121 | "symfony/config": "~2.3|3.0.*", 122 | "symfony/css-selector": "~2.3|3.0.*", 123 | "symfony/debug": "~2.3|3.0.*", 124 | "symfony/dom-crawler": "~2.3|3.0.*", 125 | "symfony/finder": "~2.3|3.0.*", 126 | "symfony/form": "~2.3|3.0.*", 127 | "symfony/locale": "~2.3|3.0.*", 128 | "symfony/monolog-bridge": "~2.3|3.0.*", 129 | "symfony/options-resolver": "~2.3|3.0.*", 130 | "symfony/phpunit-bridge": "~2.7", 131 | "symfony/process": "~2.3|3.0.*", 132 | "symfony/security": "~2.3|3.0.*", 133 | "symfony/serializer": "~2.3|3.0.*", 134 | "symfony/translation": "~2.3|3.0.*", 135 | "symfony/twig-bridge": "~2.3|3.0.*", 136 | "symfony/validator": "~2.3|3.0.*", 137 | "twig/twig": "~1.8|~2.0" 138 | }, 139 | "type": "library", 140 | "extra": { 141 | "branch-alias": { 142 | "dev-master": "1.3.x-dev" 143 | } 144 | }, 145 | "autoload": { 146 | "psr-4": { 147 | "Silex\\": "src/Silex" 148 | } 149 | }, 150 | "notification-url": "https://packagist.org/downloads/", 151 | "license": [ 152 | "MIT" 153 | ], 154 | "authors": [ 155 | { 156 | "name": "Fabien Potencier", 157 | "email": "fabien@symfony.com" 158 | }, 159 | { 160 | "name": "Igor Wiedler", 161 | "email": "igor@wiedler.ch" 162 | } 163 | ], 164 | "description": "The PHP micro-framework based on the Symfony Components", 165 | "homepage": "http://silex.sensiolabs.org", 166 | "keywords": [ 167 | "microframework" 168 | ], 169 | "time": "2015-09-15 06:53:42" 170 | }, 171 | { 172 | "name": "symfony/debug", 173 | "version": "v2.7.5", 174 | "source": { 175 | "type": "git", 176 | "url": "https://github.com/symfony/debug.git", 177 | "reference": "c79c361bca8e5ada6a47603875a3c964d03b67b1" 178 | }, 179 | "dist": { 180 | "type": "zip", 181 | "url": "https://api.github.com/repos/symfony/debug/zipball/c79c361bca8e5ada6a47603875a3c964d03b67b1", 182 | "reference": "c79c361bca8e5ada6a47603875a3c964d03b67b1", 183 | "shasum": "" 184 | }, 185 | "require": { 186 | "php": ">=5.3.9", 187 | "psr/log": "~1.0" 188 | }, 189 | "conflict": { 190 | "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" 191 | }, 192 | "require-dev": { 193 | "symfony/class-loader": "~2.2", 194 | "symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2", 195 | "symfony/phpunit-bridge": "~2.7" 196 | }, 197 | "type": "library", 198 | "extra": { 199 | "branch-alias": { 200 | "dev-master": "2.7-dev" 201 | } 202 | }, 203 | "autoload": { 204 | "psr-4": { 205 | "Symfony\\Component\\Debug\\": "" 206 | } 207 | }, 208 | "notification-url": "https://packagist.org/downloads/", 209 | "license": [ 210 | "MIT" 211 | ], 212 | "authors": [ 213 | { 214 | "name": "Fabien Potencier", 215 | "email": "fabien@symfony.com" 216 | }, 217 | { 218 | "name": "Symfony Community", 219 | "homepage": "https://symfony.com/contributors" 220 | } 221 | ], 222 | "description": "Symfony Debug Component", 223 | "homepage": "https://symfony.com", 224 | "time": "2015-09-14 08:41:38" 225 | }, 226 | { 227 | "name": "symfony/event-dispatcher", 228 | "version": "v2.7.5", 229 | "source": { 230 | "type": "git", 231 | "url": "https://github.com/symfony/event-dispatcher.git", 232 | "reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9" 233 | }, 234 | "dist": { 235 | "type": "zip", 236 | "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae4dcc2a8d3de98bd794167a3ccda1311597c5d9", 237 | "reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9", 238 | "shasum": "" 239 | }, 240 | "require": { 241 | "php": ">=5.3.9" 242 | }, 243 | "require-dev": { 244 | "psr/log": "~1.0", 245 | "symfony/config": "~2.0,>=2.0.5", 246 | "symfony/dependency-injection": "~2.6", 247 | "symfony/expression-language": "~2.6", 248 | "symfony/phpunit-bridge": "~2.7", 249 | "symfony/stopwatch": "~2.3" 250 | }, 251 | "suggest": { 252 | "symfony/dependency-injection": "", 253 | "symfony/http-kernel": "" 254 | }, 255 | "type": "library", 256 | "extra": { 257 | "branch-alias": { 258 | "dev-master": "2.7-dev" 259 | } 260 | }, 261 | "autoload": { 262 | "psr-4": { 263 | "Symfony\\Component\\EventDispatcher\\": "" 264 | } 265 | }, 266 | "notification-url": "https://packagist.org/downloads/", 267 | "license": [ 268 | "MIT" 269 | ], 270 | "authors": [ 271 | { 272 | "name": "Fabien Potencier", 273 | "email": "fabien@symfony.com" 274 | }, 275 | { 276 | "name": "Symfony Community", 277 | "homepage": "https://symfony.com/contributors" 278 | } 279 | ], 280 | "description": "Symfony EventDispatcher Component", 281 | "homepage": "https://symfony.com", 282 | "time": "2015-09-22 13:49:29" 283 | }, 284 | { 285 | "name": "symfony/http-foundation", 286 | "version": "v2.7.5", 287 | "source": { 288 | "type": "git", 289 | "url": "https://github.com/symfony/http-foundation.git", 290 | "reference": "e1509119f164a0d0a940d7d924d693a7a28a5470" 291 | }, 292 | "dist": { 293 | "type": "zip", 294 | "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e1509119f164a0d0a940d7d924d693a7a28a5470", 295 | "reference": "e1509119f164a0d0a940d7d924d693a7a28a5470", 296 | "shasum": "" 297 | }, 298 | "require": { 299 | "php": ">=5.3.9" 300 | }, 301 | "require-dev": { 302 | "symfony/expression-language": "~2.4", 303 | "symfony/phpunit-bridge": "~2.7" 304 | }, 305 | "type": "library", 306 | "extra": { 307 | "branch-alias": { 308 | "dev-master": "2.7-dev" 309 | } 310 | }, 311 | "autoload": { 312 | "psr-4": { 313 | "Symfony\\Component\\HttpFoundation\\": "" 314 | }, 315 | "classmap": [ 316 | "Resources/stubs" 317 | ] 318 | }, 319 | "notification-url": "https://packagist.org/downloads/", 320 | "license": [ 321 | "MIT" 322 | ], 323 | "authors": [ 324 | { 325 | "name": "Fabien Potencier", 326 | "email": "fabien@symfony.com" 327 | }, 328 | { 329 | "name": "Symfony Community", 330 | "homepage": "https://symfony.com/contributors" 331 | } 332 | ], 333 | "description": "Symfony HttpFoundation Component", 334 | "homepage": "https://symfony.com", 335 | "time": "2015-09-22 13:49:29" 336 | }, 337 | { 338 | "name": "symfony/http-kernel", 339 | "version": "v2.7.5", 340 | "source": { 341 | "type": "git", 342 | "url": "https://github.com/symfony/http-kernel.git", 343 | "reference": "353aa457424262d7d4e4289ea483145921cffcb5" 344 | }, 345 | "dist": { 346 | "type": "zip", 347 | "url": "https://api.github.com/repos/symfony/http-kernel/zipball/353aa457424262d7d4e4289ea483145921cffcb5", 348 | "reference": "353aa457424262d7d4e4289ea483145921cffcb5", 349 | "shasum": "" 350 | }, 351 | "require": { 352 | "php": ">=5.3.9", 353 | "psr/log": "~1.0", 354 | "symfony/debug": "~2.6,>=2.6.2", 355 | "symfony/event-dispatcher": "~2.6,>=2.6.7", 356 | "symfony/http-foundation": "~2.5,>=2.5.4" 357 | }, 358 | "conflict": { 359 | "symfony/config": "<2.7" 360 | }, 361 | "require-dev": { 362 | "symfony/browser-kit": "~2.3", 363 | "symfony/class-loader": "~2.1", 364 | "symfony/config": "~2.7", 365 | "symfony/console": "~2.3", 366 | "symfony/css-selector": "~2.0,>=2.0.5", 367 | "symfony/dependency-injection": "~2.2", 368 | "symfony/dom-crawler": "~2.0,>=2.0.5", 369 | "symfony/expression-language": "~2.4", 370 | "symfony/finder": "~2.0,>=2.0.5", 371 | "symfony/phpunit-bridge": "~2.7", 372 | "symfony/process": "~2.0,>=2.0.5", 373 | "symfony/routing": "~2.2", 374 | "symfony/stopwatch": "~2.3", 375 | "symfony/templating": "~2.2", 376 | "symfony/translation": "~2.0,>=2.0.5", 377 | "symfony/var-dumper": "~2.6" 378 | }, 379 | "suggest": { 380 | "symfony/browser-kit": "", 381 | "symfony/class-loader": "", 382 | "symfony/config": "", 383 | "symfony/console": "", 384 | "symfony/dependency-injection": "", 385 | "symfony/finder": "", 386 | "symfony/var-dumper": "" 387 | }, 388 | "type": "library", 389 | "extra": { 390 | "branch-alias": { 391 | "dev-master": "2.7-dev" 392 | } 393 | }, 394 | "autoload": { 395 | "psr-4": { 396 | "Symfony\\Component\\HttpKernel\\": "" 397 | } 398 | }, 399 | "notification-url": "https://packagist.org/downloads/", 400 | "license": [ 401 | "MIT" 402 | ], 403 | "authors": [ 404 | { 405 | "name": "Fabien Potencier", 406 | "email": "fabien@symfony.com" 407 | }, 408 | { 409 | "name": "Symfony Community", 410 | "homepage": "https://symfony.com/contributors" 411 | } 412 | ], 413 | "description": "Symfony HttpKernel Component", 414 | "homepage": "https://symfony.com", 415 | "time": "2015-09-25 11:16:52" 416 | }, 417 | { 418 | "name": "symfony/options-resolver", 419 | "version": "v2.7.5", 420 | "source": { 421 | "type": "git", 422 | "url": "https://github.com/symfony/options-resolver.git", 423 | "reference": "75389f6f948edfdf0c0ebdbe00c4f84ab5d1a03e" 424 | }, 425 | "dist": { 426 | "type": "zip", 427 | "url": "https://api.github.com/repos/symfony/options-resolver/zipball/75389f6f948edfdf0c0ebdbe00c4f84ab5d1a03e", 428 | "reference": "75389f6f948edfdf0c0ebdbe00c4f84ab5d1a03e", 429 | "shasum": "" 430 | }, 431 | "require": { 432 | "php": ">=5.3.9" 433 | }, 434 | "require-dev": { 435 | "symfony/phpunit-bridge": "~2.7" 436 | }, 437 | "type": "library", 438 | "extra": { 439 | "branch-alias": { 440 | "dev-master": "2.7-dev" 441 | } 442 | }, 443 | "autoload": { 444 | "psr-4": { 445 | "Symfony\\Component\\OptionsResolver\\": "" 446 | } 447 | }, 448 | "notification-url": "https://packagist.org/downloads/", 449 | "license": [ 450 | "MIT" 451 | ], 452 | "authors": [ 453 | { 454 | "name": "Fabien Potencier", 455 | "email": "fabien@symfony.com" 456 | }, 457 | { 458 | "name": "Symfony Community", 459 | "homepage": "https://symfony.com/contributors" 460 | } 461 | ], 462 | "description": "Symfony OptionsResolver Component", 463 | "homepage": "https://symfony.com", 464 | "keywords": [ 465 | "config", 466 | "configuration", 467 | "options" 468 | ], 469 | "time": "2015-09-25 06:59:16" 470 | }, 471 | { 472 | "name": "symfony/routing", 473 | "version": "v2.7.5", 474 | "source": { 475 | "type": "git", 476 | "url": "https://github.com/symfony/routing.git", 477 | "reference": "6c5fae83efa20baf166fcf4582f57094e9f60f16" 478 | }, 479 | "dist": { 480 | "type": "zip", 481 | "url": "https://api.github.com/repos/symfony/routing/zipball/6c5fae83efa20baf166fcf4582f57094e9f60f16", 482 | "reference": "6c5fae83efa20baf166fcf4582f57094e9f60f16", 483 | "shasum": "" 484 | }, 485 | "require": { 486 | "php": ">=5.3.9" 487 | }, 488 | "conflict": { 489 | "symfony/config": "<2.7" 490 | }, 491 | "require-dev": { 492 | "doctrine/annotations": "~1.0", 493 | "doctrine/common": "~2.2", 494 | "psr/log": "~1.0", 495 | "symfony/config": "~2.7", 496 | "symfony/expression-language": "~2.4", 497 | "symfony/http-foundation": "~2.3", 498 | "symfony/phpunit-bridge": "~2.7", 499 | "symfony/yaml": "~2.0,>=2.0.5" 500 | }, 501 | "suggest": { 502 | "doctrine/annotations": "For using the annotation loader", 503 | "symfony/config": "For using the all-in-one router or any loader", 504 | "symfony/expression-language": "For using expression matching", 505 | "symfony/yaml": "For using the YAML loader" 506 | }, 507 | "type": "library", 508 | "extra": { 509 | "branch-alias": { 510 | "dev-master": "2.7-dev" 511 | } 512 | }, 513 | "autoload": { 514 | "psr-4": { 515 | "Symfony\\Component\\Routing\\": "" 516 | } 517 | }, 518 | "notification-url": "https://packagist.org/downloads/", 519 | "license": [ 520 | "MIT" 521 | ], 522 | "authors": [ 523 | { 524 | "name": "Fabien Potencier", 525 | "email": "fabien@symfony.com" 526 | }, 527 | { 528 | "name": "Symfony Community", 529 | "homepage": "https://symfony.com/contributors" 530 | } 531 | ], 532 | "description": "Symfony Routing Component", 533 | "homepage": "https://symfony.com", 534 | "keywords": [ 535 | "router", 536 | "routing", 537 | "uri", 538 | "url" 539 | ], 540 | "time": "2015-09-14 14:14:09" 541 | } 542 | ], 543 | "packages-dev": [ 544 | { 545 | "name": "doctrine/instantiator", 546 | "version": "1.0.5", 547 | "source": { 548 | "type": "git", 549 | "url": "https://github.com/doctrine/instantiator.git", 550 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" 551 | }, 552 | "dist": { 553 | "type": "zip", 554 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", 555 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", 556 | "shasum": "" 557 | }, 558 | "require": { 559 | "php": ">=5.3,<8.0-DEV" 560 | }, 561 | "require-dev": { 562 | "athletic/athletic": "~0.1.8", 563 | "ext-pdo": "*", 564 | "ext-phar": "*", 565 | "phpunit/phpunit": "~4.0", 566 | "squizlabs/php_codesniffer": "~2.0" 567 | }, 568 | "type": "library", 569 | "extra": { 570 | "branch-alias": { 571 | "dev-master": "1.0.x-dev" 572 | } 573 | }, 574 | "autoload": { 575 | "psr-4": { 576 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 577 | } 578 | }, 579 | "notification-url": "https://packagist.org/downloads/", 580 | "license": [ 581 | "MIT" 582 | ], 583 | "authors": [ 584 | { 585 | "name": "Marco Pivetta", 586 | "email": "ocramius@gmail.com", 587 | "homepage": "http://ocramius.github.com/" 588 | } 589 | ], 590 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 591 | "homepage": "https://github.com/doctrine/instantiator", 592 | "keywords": [ 593 | "constructor", 594 | "instantiate" 595 | ], 596 | "time": "2015-06-14 21:17:01" 597 | }, 598 | { 599 | "name": "phpdocumentor/reflection-docblock", 600 | "version": "2.0.4", 601 | "source": { 602 | "type": "git", 603 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 604 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" 605 | }, 606 | "dist": { 607 | "type": "zip", 608 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", 609 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", 610 | "shasum": "" 611 | }, 612 | "require": { 613 | "php": ">=5.3.3" 614 | }, 615 | "require-dev": { 616 | "phpunit/phpunit": "~4.0" 617 | }, 618 | "suggest": { 619 | "dflydev/markdown": "~1.0", 620 | "erusev/parsedown": "~1.0" 621 | }, 622 | "type": "library", 623 | "extra": { 624 | "branch-alias": { 625 | "dev-master": "2.0.x-dev" 626 | } 627 | }, 628 | "autoload": { 629 | "psr-0": { 630 | "phpDocumentor": [ 631 | "src/" 632 | ] 633 | } 634 | }, 635 | "notification-url": "https://packagist.org/downloads/", 636 | "license": [ 637 | "MIT" 638 | ], 639 | "authors": [ 640 | { 641 | "name": "Mike van Riel", 642 | "email": "mike.vanriel@naenius.com" 643 | } 644 | ], 645 | "time": "2015-02-03 12:10:50" 646 | }, 647 | { 648 | "name": "phpspec/prophecy", 649 | "version": "v1.5.0", 650 | "source": { 651 | "type": "git", 652 | "url": "https://github.com/phpspec/prophecy.git", 653 | "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7" 654 | }, 655 | "dist": { 656 | "type": "zip", 657 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7", 658 | "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7", 659 | "shasum": "" 660 | }, 661 | "require": { 662 | "doctrine/instantiator": "^1.0.2", 663 | "phpdocumentor/reflection-docblock": "~2.0", 664 | "sebastian/comparator": "~1.1" 665 | }, 666 | "require-dev": { 667 | "phpspec/phpspec": "~2.0" 668 | }, 669 | "type": "library", 670 | "extra": { 671 | "branch-alias": { 672 | "dev-master": "1.4.x-dev" 673 | } 674 | }, 675 | "autoload": { 676 | "psr-0": { 677 | "Prophecy\\": "src/" 678 | } 679 | }, 680 | "notification-url": "https://packagist.org/downloads/", 681 | "license": [ 682 | "MIT" 683 | ], 684 | "authors": [ 685 | { 686 | "name": "Konstantin Kudryashov", 687 | "email": "ever.zet@gmail.com", 688 | "homepage": "http://everzet.com" 689 | }, 690 | { 691 | "name": "Marcello Duarte", 692 | "email": "marcello.duarte@gmail.com" 693 | } 694 | ], 695 | "description": "Highly opinionated mocking framework for PHP 5.3+", 696 | "homepage": "https://github.com/phpspec/prophecy", 697 | "keywords": [ 698 | "Double", 699 | "Dummy", 700 | "fake", 701 | "mock", 702 | "spy", 703 | "stub" 704 | ], 705 | "time": "2015-08-13 10:07:40" 706 | }, 707 | { 708 | "name": "phpunit/php-code-coverage", 709 | "version": "2.2.3", 710 | "source": { 711 | "type": "git", 712 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 713 | "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f" 714 | }, 715 | "dist": { 716 | "type": "zip", 717 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f", 718 | "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f", 719 | "shasum": "" 720 | }, 721 | "require": { 722 | "php": ">=5.3.3", 723 | "phpunit/php-file-iterator": "~1.3", 724 | "phpunit/php-text-template": "~1.2", 725 | "phpunit/php-token-stream": "~1.3", 726 | "sebastian/environment": "^1.3.2", 727 | "sebastian/version": "~1.0" 728 | }, 729 | "require-dev": { 730 | "ext-xdebug": ">=2.1.4", 731 | "phpunit/phpunit": "~4" 732 | }, 733 | "suggest": { 734 | "ext-dom": "*", 735 | "ext-xdebug": ">=2.2.1", 736 | "ext-xmlwriter": "*" 737 | }, 738 | "type": "library", 739 | "extra": { 740 | "branch-alias": { 741 | "dev-master": "2.2.x-dev" 742 | } 743 | }, 744 | "autoload": { 745 | "classmap": [ 746 | "src/" 747 | ] 748 | }, 749 | "notification-url": "https://packagist.org/downloads/", 750 | "license": [ 751 | "BSD-3-Clause" 752 | ], 753 | "authors": [ 754 | { 755 | "name": "Sebastian Bergmann", 756 | "email": "sb@sebastian-bergmann.de", 757 | "role": "lead" 758 | } 759 | ], 760 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 761 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 762 | "keywords": [ 763 | "coverage", 764 | "testing", 765 | "xunit" 766 | ], 767 | "time": "2015-09-14 06:51:16" 768 | }, 769 | { 770 | "name": "phpunit/php-file-iterator", 771 | "version": "1.4.1", 772 | "source": { 773 | "type": "git", 774 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 775 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" 776 | }, 777 | "dist": { 778 | "type": "zip", 779 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", 780 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", 781 | "shasum": "" 782 | }, 783 | "require": { 784 | "php": ">=5.3.3" 785 | }, 786 | "type": "library", 787 | "extra": { 788 | "branch-alias": { 789 | "dev-master": "1.4.x-dev" 790 | } 791 | }, 792 | "autoload": { 793 | "classmap": [ 794 | "src/" 795 | ] 796 | }, 797 | "notification-url": "https://packagist.org/downloads/", 798 | "license": [ 799 | "BSD-3-Clause" 800 | ], 801 | "authors": [ 802 | { 803 | "name": "Sebastian Bergmann", 804 | "email": "sb@sebastian-bergmann.de", 805 | "role": "lead" 806 | } 807 | ], 808 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 809 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 810 | "keywords": [ 811 | "filesystem", 812 | "iterator" 813 | ], 814 | "time": "2015-06-21 13:08:43" 815 | }, 816 | { 817 | "name": "phpunit/php-text-template", 818 | "version": "1.2.1", 819 | "source": { 820 | "type": "git", 821 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 822 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 823 | }, 824 | "dist": { 825 | "type": "zip", 826 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 827 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 828 | "shasum": "" 829 | }, 830 | "require": { 831 | "php": ">=5.3.3" 832 | }, 833 | "type": "library", 834 | "autoload": { 835 | "classmap": [ 836 | "src/" 837 | ] 838 | }, 839 | "notification-url": "https://packagist.org/downloads/", 840 | "license": [ 841 | "BSD-3-Clause" 842 | ], 843 | "authors": [ 844 | { 845 | "name": "Sebastian Bergmann", 846 | "email": "sebastian@phpunit.de", 847 | "role": "lead" 848 | } 849 | ], 850 | "description": "Simple template engine.", 851 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 852 | "keywords": [ 853 | "template" 854 | ], 855 | "time": "2015-06-21 13:50:34" 856 | }, 857 | { 858 | "name": "phpunit/php-timer", 859 | "version": "1.0.7", 860 | "source": { 861 | "type": "git", 862 | "url": "https://github.com/sebastianbergmann/php-timer.git", 863 | "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" 864 | }, 865 | "dist": { 866 | "type": "zip", 867 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", 868 | "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", 869 | "shasum": "" 870 | }, 871 | "require": { 872 | "php": ">=5.3.3" 873 | }, 874 | "type": "library", 875 | "autoload": { 876 | "classmap": [ 877 | "src/" 878 | ] 879 | }, 880 | "notification-url": "https://packagist.org/downloads/", 881 | "license": [ 882 | "BSD-3-Clause" 883 | ], 884 | "authors": [ 885 | { 886 | "name": "Sebastian Bergmann", 887 | "email": "sb@sebastian-bergmann.de", 888 | "role": "lead" 889 | } 890 | ], 891 | "description": "Utility class for timing", 892 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 893 | "keywords": [ 894 | "timer" 895 | ], 896 | "time": "2015-06-21 08:01:12" 897 | }, 898 | { 899 | "name": "phpunit/php-token-stream", 900 | "version": "1.4.8", 901 | "source": { 902 | "type": "git", 903 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 904 | "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" 905 | }, 906 | "dist": { 907 | "type": "zip", 908 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", 909 | "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", 910 | "shasum": "" 911 | }, 912 | "require": { 913 | "ext-tokenizer": "*", 914 | "php": ">=5.3.3" 915 | }, 916 | "require-dev": { 917 | "phpunit/phpunit": "~4.2" 918 | }, 919 | "type": "library", 920 | "extra": { 921 | "branch-alias": { 922 | "dev-master": "1.4-dev" 923 | } 924 | }, 925 | "autoload": { 926 | "classmap": [ 927 | "src/" 928 | ] 929 | }, 930 | "notification-url": "https://packagist.org/downloads/", 931 | "license": [ 932 | "BSD-3-Clause" 933 | ], 934 | "authors": [ 935 | { 936 | "name": "Sebastian Bergmann", 937 | "email": "sebastian@phpunit.de" 938 | } 939 | ], 940 | "description": "Wrapper around PHP's tokenizer extension.", 941 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 942 | "keywords": [ 943 | "tokenizer" 944 | ], 945 | "time": "2015-09-15 10:49:45" 946 | }, 947 | { 948 | "name": "phpunit/phpunit", 949 | "version": "4.8.10", 950 | "source": { 951 | "type": "git", 952 | "url": "https://github.com/sebastianbergmann/phpunit.git", 953 | "reference": "463163747474815c5ccd4ae12b5b355ec12158e8" 954 | }, 955 | "dist": { 956 | "type": "zip", 957 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/463163747474815c5ccd4ae12b5b355ec12158e8", 958 | "reference": "463163747474815c5ccd4ae12b5b355ec12158e8", 959 | "shasum": "" 960 | }, 961 | "require": { 962 | "ext-dom": "*", 963 | "ext-json": "*", 964 | "ext-pcre": "*", 965 | "ext-reflection": "*", 966 | "ext-spl": "*", 967 | "php": ">=5.3.3", 968 | "phpspec/prophecy": "^1.3.1", 969 | "phpunit/php-code-coverage": "~2.1", 970 | "phpunit/php-file-iterator": "~1.4", 971 | "phpunit/php-text-template": "~1.2", 972 | "phpunit/php-timer": ">=1.0.6", 973 | "phpunit/phpunit-mock-objects": "~2.3", 974 | "sebastian/comparator": "~1.1", 975 | "sebastian/diff": "~1.2", 976 | "sebastian/environment": "~1.3", 977 | "sebastian/exporter": "~1.2", 978 | "sebastian/global-state": "~1.0", 979 | "sebastian/version": "~1.0", 980 | "symfony/yaml": "~2.1|~3.0" 981 | }, 982 | "suggest": { 983 | "phpunit/php-invoker": "~1.1" 984 | }, 985 | "bin": [ 986 | "phpunit" 987 | ], 988 | "type": "library", 989 | "extra": { 990 | "branch-alias": { 991 | "dev-master": "4.8.x-dev" 992 | } 993 | }, 994 | "autoload": { 995 | "classmap": [ 996 | "src/" 997 | ] 998 | }, 999 | "notification-url": "https://packagist.org/downloads/", 1000 | "license": [ 1001 | "BSD-3-Clause" 1002 | ], 1003 | "authors": [ 1004 | { 1005 | "name": "Sebastian Bergmann", 1006 | "email": "sebastian@phpunit.de", 1007 | "role": "lead" 1008 | } 1009 | ], 1010 | "description": "The PHP Unit Testing framework.", 1011 | "homepage": "https://phpunit.de/", 1012 | "keywords": [ 1013 | "phpunit", 1014 | "testing", 1015 | "xunit" 1016 | ], 1017 | "time": "2015-10-01 09:14:30" 1018 | }, 1019 | { 1020 | "name": "phpunit/phpunit-mock-objects", 1021 | "version": "2.3.8", 1022 | "source": { 1023 | "type": "git", 1024 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 1025 | "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" 1026 | }, 1027 | "dist": { 1028 | "type": "zip", 1029 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", 1030 | "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", 1031 | "shasum": "" 1032 | }, 1033 | "require": { 1034 | "doctrine/instantiator": "^1.0.2", 1035 | "php": ">=5.3.3", 1036 | "phpunit/php-text-template": "~1.2", 1037 | "sebastian/exporter": "~1.2" 1038 | }, 1039 | "require-dev": { 1040 | "phpunit/phpunit": "~4.4" 1041 | }, 1042 | "suggest": { 1043 | "ext-soap": "*" 1044 | }, 1045 | "type": "library", 1046 | "extra": { 1047 | "branch-alias": { 1048 | "dev-master": "2.3.x-dev" 1049 | } 1050 | }, 1051 | "autoload": { 1052 | "classmap": [ 1053 | "src/" 1054 | ] 1055 | }, 1056 | "notification-url": "https://packagist.org/downloads/", 1057 | "license": [ 1058 | "BSD-3-Clause" 1059 | ], 1060 | "authors": [ 1061 | { 1062 | "name": "Sebastian Bergmann", 1063 | "email": "sb@sebastian-bergmann.de", 1064 | "role": "lead" 1065 | } 1066 | ], 1067 | "description": "Mock Object library for PHPUnit", 1068 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 1069 | "keywords": [ 1070 | "mock", 1071 | "xunit" 1072 | ], 1073 | "time": "2015-10-02 06:51:40" 1074 | }, 1075 | { 1076 | "name": "sebastian/comparator", 1077 | "version": "1.2.0", 1078 | "source": { 1079 | "type": "git", 1080 | "url": "https://github.com/sebastianbergmann/comparator.git", 1081 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" 1082 | }, 1083 | "dist": { 1084 | "type": "zip", 1085 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", 1086 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", 1087 | "shasum": "" 1088 | }, 1089 | "require": { 1090 | "php": ">=5.3.3", 1091 | "sebastian/diff": "~1.2", 1092 | "sebastian/exporter": "~1.2" 1093 | }, 1094 | "require-dev": { 1095 | "phpunit/phpunit": "~4.4" 1096 | }, 1097 | "type": "library", 1098 | "extra": { 1099 | "branch-alias": { 1100 | "dev-master": "1.2.x-dev" 1101 | } 1102 | }, 1103 | "autoload": { 1104 | "classmap": [ 1105 | "src/" 1106 | ] 1107 | }, 1108 | "notification-url": "https://packagist.org/downloads/", 1109 | "license": [ 1110 | "BSD-3-Clause" 1111 | ], 1112 | "authors": [ 1113 | { 1114 | "name": "Jeff Welch", 1115 | "email": "whatthejeff@gmail.com" 1116 | }, 1117 | { 1118 | "name": "Volker Dusch", 1119 | "email": "github@wallbash.com" 1120 | }, 1121 | { 1122 | "name": "Bernhard Schussek", 1123 | "email": "bschussek@2bepublished.at" 1124 | }, 1125 | { 1126 | "name": "Sebastian Bergmann", 1127 | "email": "sebastian@phpunit.de" 1128 | } 1129 | ], 1130 | "description": "Provides the functionality to compare PHP values for equality", 1131 | "homepage": "http://www.github.com/sebastianbergmann/comparator", 1132 | "keywords": [ 1133 | "comparator", 1134 | "compare", 1135 | "equality" 1136 | ], 1137 | "time": "2015-07-26 15:48:44" 1138 | }, 1139 | { 1140 | "name": "sebastian/diff", 1141 | "version": "1.3.0", 1142 | "source": { 1143 | "type": "git", 1144 | "url": "https://github.com/sebastianbergmann/diff.git", 1145 | "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" 1146 | }, 1147 | "dist": { 1148 | "type": "zip", 1149 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", 1150 | "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", 1151 | "shasum": "" 1152 | }, 1153 | "require": { 1154 | "php": ">=5.3.3" 1155 | }, 1156 | "require-dev": { 1157 | "phpunit/phpunit": "~4.2" 1158 | }, 1159 | "type": "library", 1160 | "extra": { 1161 | "branch-alias": { 1162 | "dev-master": "1.3-dev" 1163 | } 1164 | }, 1165 | "autoload": { 1166 | "classmap": [ 1167 | "src/" 1168 | ] 1169 | }, 1170 | "notification-url": "https://packagist.org/downloads/", 1171 | "license": [ 1172 | "BSD-3-Clause" 1173 | ], 1174 | "authors": [ 1175 | { 1176 | "name": "Kore Nordmann", 1177 | "email": "mail@kore-nordmann.de" 1178 | }, 1179 | { 1180 | "name": "Sebastian Bergmann", 1181 | "email": "sebastian@phpunit.de" 1182 | } 1183 | ], 1184 | "description": "Diff implementation", 1185 | "homepage": "http://www.github.com/sebastianbergmann/diff", 1186 | "keywords": [ 1187 | "diff" 1188 | ], 1189 | "time": "2015-02-22 15:13:53" 1190 | }, 1191 | { 1192 | "name": "sebastian/environment", 1193 | "version": "1.3.2", 1194 | "source": { 1195 | "type": "git", 1196 | "url": "https://github.com/sebastianbergmann/environment.git", 1197 | "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44" 1198 | }, 1199 | "dist": { 1200 | "type": "zip", 1201 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44", 1202 | "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44", 1203 | "shasum": "" 1204 | }, 1205 | "require": { 1206 | "php": ">=5.3.3" 1207 | }, 1208 | "require-dev": { 1209 | "phpunit/phpunit": "~4.4" 1210 | }, 1211 | "type": "library", 1212 | "extra": { 1213 | "branch-alias": { 1214 | "dev-master": "1.3.x-dev" 1215 | } 1216 | }, 1217 | "autoload": { 1218 | "classmap": [ 1219 | "src/" 1220 | ] 1221 | }, 1222 | "notification-url": "https://packagist.org/downloads/", 1223 | "license": [ 1224 | "BSD-3-Clause" 1225 | ], 1226 | "authors": [ 1227 | { 1228 | "name": "Sebastian Bergmann", 1229 | "email": "sebastian@phpunit.de" 1230 | } 1231 | ], 1232 | "description": "Provides functionality to handle HHVM/PHP environments", 1233 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1234 | "keywords": [ 1235 | "Xdebug", 1236 | "environment", 1237 | "hhvm" 1238 | ], 1239 | "time": "2015-08-03 06:14:51" 1240 | }, 1241 | { 1242 | "name": "sebastian/exporter", 1243 | "version": "1.2.1", 1244 | "source": { 1245 | "type": "git", 1246 | "url": "https://github.com/sebastianbergmann/exporter.git", 1247 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e" 1248 | }, 1249 | "dist": { 1250 | "type": "zip", 1251 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", 1252 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e", 1253 | "shasum": "" 1254 | }, 1255 | "require": { 1256 | "php": ">=5.3.3", 1257 | "sebastian/recursion-context": "~1.0" 1258 | }, 1259 | "require-dev": { 1260 | "phpunit/phpunit": "~4.4" 1261 | }, 1262 | "type": "library", 1263 | "extra": { 1264 | "branch-alias": { 1265 | "dev-master": "1.2.x-dev" 1266 | } 1267 | }, 1268 | "autoload": { 1269 | "classmap": [ 1270 | "src/" 1271 | ] 1272 | }, 1273 | "notification-url": "https://packagist.org/downloads/", 1274 | "license": [ 1275 | "BSD-3-Clause" 1276 | ], 1277 | "authors": [ 1278 | { 1279 | "name": "Jeff Welch", 1280 | "email": "whatthejeff@gmail.com" 1281 | }, 1282 | { 1283 | "name": "Volker Dusch", 1284 | "email": "github@wallbash.com" 1285 | }, 1286 | { 1287 | "name": "Bernhard Schussek", 1288 | "email": "bschussek@2bepublished.at" 1289 | }, 1290 | { 1291 | "name": "Sebastian Bergmann", 1292 | "email": "sebastian@phpunit.de" 1293 | }, 1294 | { 1295 | "name": "Adam Harvey", 1296 | "email": "aharvey@php.net" 1297 | } 1298 | ], 1299 | "description": "Provides the functionality to export PHP variables for visualization", 1300 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1301 | "keywords": [ 1302 | "export", 1303 | "exporter" 1304 | ], 1305 | "time": "2015-06-21 07:55:53" 1306 | }, 1307 | { 1308 | "name": "sebastian/global-state", 1309 | "version": "1.0.0", 1310 | "source": { 1311 | "type": "git", 1312 | "url": "https://github.com/sebastianbergmann/global-state.git", 1313 | "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" 1314 | }, 1315 | "dist": { 1316 | "type": "zip", 1317 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", 1318 | "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", 1319 | "shasum": "" 1320 | }, 1321 | "require": { 1322 | "php": ">=5.3.3" 1323 | }, 1324 | "require-dev": { 1325 | "phpunit/phpunit": "~4.2" 1326 | }, 1327 | "suggest": { 1328 | "ext-uopz": "*" 1329 | }, 1330 | "type": "library", 1331 | "extra": { 1332 | "branch-alias": { 1333 | "dev-master": "1.0-dev" 1334 | } 1335 | }, 1336 | "autoload": { 1337 | "classmap": [ 1338 | "src/" 1339 | ] 1340 | }, 1341 | "notification-url": "https://packagist.org/downloads/", 1342 | "license": [ 1343 | "BSD-3-Clause" 1344 | ], 1345 | "authors": [ 1346 | { 1347 | "name": "Sebastian Bergmann", 1348 | "email": "sebastian@phpunit.de" 1349 | } 1350 | ], 1351 | "description": "Snapshotting of global state", 1352 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1353 | "keywords": [ 1354 | "global state" 1355 | ], 1356 | "time": "2014-10-06 09:23:50" 1357 | }, 1358 | { 1359 | "name": "sebastian/recursion-context", 1360 | "version": "1.0.1", 1361 | "source": { 1362 | "type": "git", 1363 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1364 | "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" 1365 | }, 1366 | "dist": { 1367 | "type": "zip", 1368 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", 1369 | "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", 1370 | "shasum": "" 1371 | }, 1372 | "require": { 1373 | "php": ">=5.3.3" 1374 | }, 1375 | "require-dev": { 1376 | "phpunit/phpunit": "~4.4" 1377 | }, 1378 | "type": "library", 1379 | "extra": { 1380 | "branch-alias": { 1381 | "dev-master": "1.0.x-dev" 1382 | } 1383 | }, 1384 | "autoload": { 1385 | "classmap": [ 1386 | "src/" 1387 | ] 1388 | }, 1389 | "notification-url": "https://packagist.org/downloads/", 1390 | "license": [ 1391 | "BSD-3-Clause" 1392 | ], 1393 | "authors": [ 1394 | { 1395 | "name": "Jeff Welch", 1396 | "email": "whatthejeff@gmail.com" 1397 | }, 1398 | { 1399 | "name": "Sebastian Bergmann", 1400 | "email": "sebastian@phpunit.de" 1401 | }, 1402 | { 1403 | "name": "Adam Harvey", 1404 | "email": "aharvey@php.net" 1405 | } 1406 | ], 1407 | "description": "Provides functionality to recursively process PHP variables", 1408 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1409 | "time": "2015-06-21 08:04:50" 1410 | }, 1411 | { 1412 | "name": "sebastian/version", 1413 | "version": "1.0.6", 1414 | "source": { 1415 | "type": "git", 1416 | "url": "https://github.com/sebastianbergmann/version.git", 1417 | "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" 1418 | }, 1419 | "dist": { 1420 | "type": "zip", 1421 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", 1422 | "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", 1423 | "shasum": "" 1424 | }, 1425 | "type": "library", 1426 | "autoload": { 1427 | "classmap": [ 1428 | "src/" 1429 | ] 1430 | }, 1431 | "notification-url": "https://packagist.org/downloads/", 1432 | "license": [ 1433 | "BSD-3-Clause" 1434 | ], 1435 | "authors": [ 1436 | { 1437 | "name": "Sebastian Bergmann", 1438 | "email": "sebastian@phpunit.de", 1439 | "role": "lead" 1440 | } 1441 | ], 1442 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1443 | "homepage": "https://github.com/sebastianbergmann/version", 1444 | "time": "2015-06-21 13:59:46" 1445 | }, 1446 | { 1447 | "name": "symfony/yaml", 1448 | "version": "v2.7.5", 1449 | "source": { 1450 | "type": "git", 1451 | "url": "https://github.com/symfony/yaml.git", 1452 | "reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770" 1453 | }, 1454 | "dist": { 1455 | "type": "zip", 1456 | "url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770", 1457 | "reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770", 1458 | "shasum": "" 1459 | }, 1460 | "require": { 1461 | "php": ">=5.3.9" 1462 | }, 1463 | "require-dev": { 1464 | "symfony/phpunit-bridge": "~2.7" 1465 | }, 1466 | "type": "library", 1467 | "extra": { 1468 | "branch-alias": { 1469 | "dev-master": "2.7-dev" 1470 | } 1471 | }, 1472 | "autoload": { 1473 | "psr-4": { 1474 | "Symfony\\Component\\Yaml\\": "" 1475 | } 1476 | }, 1477 | "notification-url": "https://packagist.org/downloads/", 1478 | "license": [ 1479 | "MIT" 1480 | ], 1481 | "authors": [ 1482 | { 1483 | "name": "Fabien Potencier", 1484 | "email": "fabien@symfony.com" 1485 | }, 1486 | { 1487 | "name": "Symfony Community", 1488 | "homepage": "https://symfony.com/contributors" 1489 | } 1490 | ], 1491 | "description": "Symfony Yaml Component", 1492 | "homepage": "https://symfony.com", 1493 | "time": "2015-09-14 14:14:09" 1494 | } 1495 | ], 1496 | "aliases": [], 1497 | "minimum-stability": "dev", 1498 | "stability-flags": [], 1499 | "prefer-stable": true, 1500 | "prefer-lowest": false, 1501 | "platform": [], 1502 | "platform-dev": [] 1503 | } 1504 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 18 | 19 | ./tests 20 | 21 | 22 | 23 | 24 | 25 | ./ 26 | 27 | ./tests 28 | ./vendor 29 | 30 | 31 | 32 | 37 | 38 | -------------------------------------------------------------------------------- /src/Config/DBlibConfig.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class DBlibConfig extends PdoConfig 11 | { 12 | protected $driver = 'dblib'; 13 | 14 | protected $defaults = array( 15 | 'host' => 'localhost', 16 | 'port' => 1433, 17 | 'MultipleActiveResultSets' => null, 18 | 'password' => null, 19 | ); 20 | 21 | protected $allowedTypes = array( 22 | 'host' => array('string'), 23 | 'port' => array('integer', 'null'), 24 | 'dbname' => array('string'), 25 | 'user' => array('string'), 26 | 'password' => array('string', 'null'), 27 | 'MultipleActiveResultSets' => array('boolean', 'null'), 28 | ); 29 | 30 | protected function resolve(array $params) 31 | { 32 | $params = parent::resolve($params); 33 | 34 | if (is_null($params['MultipleActiveResultSets'])) { 35 | unset($params['MultipleActiveResultSets']); 36 | } 37 | 38 | return $params; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Config/MySqlConfig.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class MySqlConfig extends PdoConfig 11 | { 12 | protected $driver = 'mysql'; 13 | 14 | protected $defaults = array( 15 | 'host' => 'localhost', 16 | 'port' => 3306, 17 | 'charset' => null, 18 | 'unix_socket' => null, 19 | 'password' => null, 20 | ); 21 | 22 | protected $allowedTypes = array( 23 | 'host' => array('string'), 24 | 'port' => array('integer', 'null'), 25 | 'dbname' => array('string'), 26 | 'user' => array('string'), 27 | 'password' => array('string', 'null'), 28 | 'charset' => array('string', 'null'), 29 | 'unix_socket' => array('string', 'null'), 30 | ); 31 | 32 | protected function resolve(array $params) 33 | { 34 | $params = parent::resolve($params); 35 | 36 | if (!empty($params['unix_socket'])) { 37 | unset($params['host']); 38 | unset($params['port']); 39 | } else { 40 | unset($params['unix_socket']); 41 | } 42 | 43 | return $params; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Config/OracleConfig.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class OracleConfig extends PdoConfig 11 | { 12 | protected $driver = 'oci'; 13 | 14 | protected $defaults = array( 15 | 'host' => 'localhost', 16 | 'port' => 1521, 17 | 'service' => null, 18 | 'charset' => null, 19 | 'password' => null, 20 | ); 21 | 22 | protected $allowedTypes = array( 23 | 'host' => array('string'), 24 | 'port' => array('integer', 'null'), 25 | 'dbname' => array('string'), 26 | 'user' => array('string'), 27 | 'password' => array('string', 'null'), 28 | 'service' => array('bool', 'null'), 29 | 'charset' => array('string', 'null'), 30 | ); 31 | 32 | protected function resolve(array $params) 33 | { 34 | $params = parent::resolve($params); 35 | 36 | if (isset($params['host']) && $params['host'] != null) { 37 | $dbname = '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' . 38 | '(HOST=' . $params['host'] . ')'; 39 | 40 | if (isset($params['port'])) { 41 | $dbname .= '(PORT=' . $params['port'] . ')'; 42 | } else { 43 | $dbname .= '(PORT=1521)'; 44 | } 45 | 46 | if (isset($params['service']) && $params['service'] == true) { 47 | $dbname .= '))(CONNECT_DATA=(SERVICE_NAME=' . $params['dbname'] . ')))'; 48 | } else { 49 | $dbname .= '))(CONNECT_DATA=(SID=' . $params['dbname'] . ')))'; 50 | } 51 | 52 | $params['dbname'] = $dbname; 53 | } 54 | 55 | unset($params['host']); 56 | unset($params['port']); 57 | unset($params['service']); 58 | 59 | return $params; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Config/PdoConfig.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | abstract class PdoConfig implements PdoConfigInterface 15 | { 16 | /** 17 | * 18 | * @var OptionsResolver 19 | */ 20 | protected $resolver; 21 | 22 | /** 23 | * 24 | * @var array 25 | */ 26 | protected $dsnParams; 27 | 28 | /** 29 | * 30 | * @var string 31 | */ 32 | protected $user; 33 | 34 | /** 35 | * 36 | * @var string 37 | */ 38 | protected $password; 39 | 40 | /** 41 | * 42 | * @var string 43 | */ 44 | protected $driver; 45 | 46 | /** 47 | * 48 | * @var array 49 | */ 50 | protected $required = array( 51 | 'dbname', 52 | 'user', 53 | ); 54 | 55 | /** 56 | * 57 | * @var array 58 | */ 59 | protected $defaults = array(); 60 | 61 | /** 62 | * 63 | * @var array 64 | */ 65 | protected $allowedValues = array(); 66 | 67 | /** 68 | * 69 | * @var array 70 | */ 71 | protected $allowedTypes = array(); 72 | 73 | public function __construct() 74 | { 75 | $this->allowedTypes = array_merge(array( 76 | 'driver' => array('string'), 77 | 'options' => array('array', 'null'), 78 | 'attributes' => array('array'), 79 | ), $this->allowedTypes); 80 | 81 | $this->allowedValues = array_merge(array( 82 | 'driver' => array($this->driver), 83 | ), $this->allowedValues); 84 | 85 | $this->defaults = array_merge(array( 86 | 'driver' => $this->driver, 87 | 'options' => array(), 88 | 'attributes' => array(), 89 | ), $this->defaults); 90 | 91 | $this->resolver = new OptionsResolver(); 92 | $this->resolver 93 | ->setRequired($this->required) 94 | ->setDefaults($this->defaults); 95 | 96 | foreach($this->allowedValues as $option => $value) { 97 | $this->resolver->setAllowedValues($option, $value); 98 | } 99 | 100 | foreach($this->allowedTypes as $option => $value) { 101 | $this->resolver->setAllowedTypes($option, $value); 102 | } 103 | } 104 | 105 | /** 106 | * 107 | * @param array $params 108 | * @return string dsn 109 | */ 110 | protected function constructDSN(array $params) 111 | { 112 | $driver = $params['driver']; 113 | unset($params['driver']); 114 | 115 | $dsnParams = array(); 116 | foreach ($params as $key => $value) { 117 | if ($value != null && $value != '') { 118 | $dsnParams[] = $key.'='.$value; 119 | } 120 | } 121 | 122 | return $driver.':'.implode(';', $dsnParams); 123 | } 124 | 125 | /** 126 | * 127 | * @param array $params 128 | */ 129 | protected function resolve(array $params) 130 | { 131 | return $this->resolver->resolve($params); 132 | } 133 | 134 | /** 135 | * 136 | * @param array $params 137 | */ 138 | public function prepareParameters(array $params) 139 | { 140 | $params = $this->resolve($params); 141 | $preparedParams = array(); 142 | 143 | if (isset($params['options'])) { 144 | $preparedParams['options'] = $params['options']; 145 | unset($params['options']); 146 | } 147 | 148 | if (isset($params['user'])) { 149 | $preparedParams['user'] = $params['user']; 150 | unset($params['user']); 151 | } 152 | 153 | if (isset($params['password'])) { 154 | $preparedParams['password'] = $params['password']; 155 | unset($params['password']); 156 | } 157 | 158 | if (isset($params['attributes'])) { 159 | $preparedParams['attributes'] = $params['attributes']; 160 | unset($params['attributes']); 161 | } 162 | 163 | $preparedParams['dsn'] = $this->constructDSN($params); 164 | 165 | return $preparedParams; 166 | } 167 | 168 | /** 169 | * 170 | * @param array $params 171 | * 172 | * @return \PDO 173 | */ 174 | public function connect(array $params) 175 | { 176 | $params = $this->prepareParameters($params); 177 | 178 | $pdo = new \PDO( 179 | $params['dsn'], 180 | isset($params['user']) ? (string) $params['user'] : null, 181 | isset($params['password']) ? (string) $params['password'] : null, 182 | isset($params['options']) ? (array) $params['options'] : array() 183 | ); 184 | 185 | if (is_array($params['attributes'])) { 186 | foreach ($params['attributes'] as $attr => $value) { 187 | $pdo->setAttribute($attr, $value); 188 | } 189 | } 190 | 191 | return $pdo; 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /src/Config/PdoConfigFactory.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class PdoConfigFactory 11 | { 12 | /** 13 | * 14 | * @param string $driver 15 | * 16 | * @return PdoConfigInterface 17 | */ 18 | public function createConfig($driver) 19 | { 20 | switch ($driver) { 21 | case 'pgsql': 22 | case 'postgre': 23 | case 'postgresql': 24 | $cfg = new PgSqlConfig(); 25 | break; 26 | case 'oci': 27 | case 'oracle': 28 | $cfg = new OracleConfig(); 29 | break; 30 | case 'dblib': 31 | $cfg = new DBlibConfig(); 32 | break; 33 | case 'sqlsrv': 34 | case 'sqlserver': 35 | case 'mssqlserver': 36 | case 'mssql': 37 | $cfg = new SqlSrvConfig(); 38 | break; 39 | case 'mysql': 40 | $cfg = new MySqlConfig(); 41 | break; 42 | case 'sqlite': 43 | default: 44 | $cfg = new SqliteConfig(); 45 | break; 46 | } 47 | 48 | return $cfg; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Config/PdoConfigInterface.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | interface PdoConfigInterface 11 | { 12 | /** 13 | * @param array $params 14 | * 15 | * @return array 16 | */ 17 | public function prepareParameters(array $params); 18 | 19 | /** 20 | * 21 | * @param array $params 22 | * 23 | * @return \PDO 24 | */ 25 | public function connect(array $params); 26 | } 27 | -------------------------------------------------------------------------------- /src/Config/PgSqlConfig.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class PgSqlConfig extends PdoConfig 11 | { 12 | protected $driver = 'pgsql'; 13 | 14 | protected $defaults = array( 15 | 'host' => 'localhost', 16 | 'port' => 5432, 17 | 'password' => null, 18 | ); 19 | 20 | protected $allowedTypes = array( 21 | 'host' => array('string'), 22 | 'port' => array('integer', 'null'), 23 | 'dbname' => array('string'), 24 | 'user' => array('string'), 25 | 'password' => array('string', 'null'), 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /src/Config/SqlSrvConfig.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class SqlSrvConfig extends PdoConfig 11 | { 12 | protected $driver = 'sqlsrv'; 13 | 14 | protected $defaults = array( 15 | 'host' => 'localhost', 16 | 'port' => 1433, 17 | 'MultipleActiveResultSets' => null, 18 | 'password' => null, 19 | ); 20 | 21 | protected $allowedTypes = array( 22 | 'host' => array('string'), 23 | 'port' => array('integer', 'null'), 24 | 'dbname' => array('string'), 25 | 'user' => array('string'), 26 | 'password' => array('string', 'null'), 27 | 'MultipleActiveResultSets' => array('boolean', 'null'), 28 | ); 29 | 30 | protected function resolve(array $params) 31 | { 32 | $params = parent::resolve($params); 33 | 34 | $params['server'] = $params['host']; 35 | unset($params['host']); 36 | 37 | if (is_null($params['MultipleActiveResultSets'])) { 38 | unset($params['MultipleActiveResultSets']); 39 | } 40 | 41 | return $params; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Config/SqliteConfig.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class SqliteConfig extends PdoConfig 11 | { 12 | protected $driver = 'sqlite'; 13 | 14 | protected $required = array( 15 | 'path', 16 | ); 17 | 18 | protected $defaults = array( 19 | 'path' => 'memory', 20 | ); 21 | 22 | protected $allowedTypes = array( 23 | 'driver' => array('string'), 24 | 'options' => array('array', 'null'), 25 | 'path' => array('string', 'null'), 26 | ); 27 | 28 | protected function constructDSN(array $params) 29 | { 30 | return $this->driver.':'.($params['path'] == 'memory' || empty($params['path'])? ':memory:' : $params['path']); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Provider/PDOServiceProvider.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class PDOServiceProvider implements ServiceProviderInterface 15 | { 16 | /** 17 | * @param string $prefix 18 | */ 19 | protected $prefix; 20 | 21 | /** 22 | * @param string $prefix Prefix name used to register the service provider in Silex. 23 | */ 24 | public function __construct($prefix = 'pdo') 25 | { 26 | if (empty($prefix)) { 27 | throw new \InvalidArgumentException('The specified prefix is not valid.'); 28 | } 29 | 30 | $this->prefix = $prefix; 31 | } 32 | 33 | /** 34 | * @param Application $app 35 | * @param string $prefix 36 | * 37 | * @return \PDO 38 | */ 39 | protected function getPdo(Application $app, $prefix) 40 | { 41 | return $app->share(function () use ($app, $prefix) { 42 | $factory = new PdoConfigFactory(); 43 | 44 | $app[$prefix.'.server'] = array_merge( 45 | array( 46 | 'driver' => 'sqlite', 47 | ), 48 | isset($app[$prefix.'.server']) ? (array) $app[$prefix.'.server'] : array() 49 | ); 50 | 51 | $params = array_merge( 52 | $app[$prefix.'.server'], 53 | array( 54 | 'options' => isset($app[$prefix.'.options']) ? (array) $app[$prefix.'.options'] : array(), 55 | ), 56 | array( 57 | 'attributes' => isset($app[$prefix.'.attributes']) ? (array) $app[$prefix.'.attributes'] : array(), 58 | ) 59 | ); 60 | 61 | $cfg = $factory->createConfig($params['driver']); 62 | 63 | return $cfg->connect($params); 64 | }); 65 | } 66 | 67 | /** 68 | * @param Application $app 69 | * 70 | */ 71 | public function register(Application $app) 72 | { 73 | $prefix = $this->prefix; 74 | 75 | foreach(array('.server', '.options', '.attributes') as $key) { 76 | if (!(isset($app[$prefix . $key]))) { 77 | $app[$prefix. $key] = array(); 78 | } 79 | } 80 | 81 | $app[$prefix] = $this->getPdo($app, $prefix); 82 | } 83 | 84 | /** 85 | * @param Application $app 86 | * @codeCoverageIgnore 87 | */ 88 | public function boot(Application $app) 89 | { 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /tests/Config/DBlibConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class DBlibConfigTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var DBlibConfig 17 | */ 18 | protected $pdoConfig; 19 | 20 | public function setUp() 21 | { 22 | $this->pdoConfig = new DBlibConfig(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderPrepareParameters 27 | */ 28 | public function testPrepareParameters($params, $expected) 29 | { 30 | $result = $this->pdoConfig->prepareParameters($params); 31 | $this->assertEquals($expected, $result); 32 | } 33 | 34 | public function dataProviderPrepareParameters() 35 | { 36 | return array( 37 | array( 38 | array( 39 | 'dbname' => 'fake-db', 40 | 'user' => 'fake-user', 41 | 'password' => 'fake-password', 42 | ), 43 | array( 44 | 'dsn' => 'dblib:host=localhost;port=1433;dbname=fake-db', 45 | 'user' => 'fake-user', 46 | 'password' => 'fake-password', 47 | 'options' => array(), 48 | 'attributes' => array(), 49 | ), 50 | ), 51 | array( 52 | array( 53 | 'host' => '127.0.0.1', 54 | 'port' => null, 55 | 'dbname' => 'fake-db', 56 | 'user' => 'fake-user', 57 | 'password' => 'fake-password', 58 | 'attributes' => array(), 59 | ), 60 | array( 61 | 'dsn' => 'dblib:host=127.0.0.1;dbname=fake-db', 62 | 'user' => 'fake-user', 63 | 'password' => 'fake-password', 64 | 'options' => array(), 65 | 'attributes' => array(), 66 | ), 67 | ), 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tests/Config/MySqlConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class MySqlConfigTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var MySqlConfig 17 | */ 18 | protected $pdoConfig; 19 | 20 | public function setUp() 21 | { 22 | $this->pdoConfig = new MySqlConfig(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderPrepareParameters 27 | */ 28 | public function testPrepareParameters($params, $expected) 29 | { 30 | $result = $this->pdoConfig->prepareParameters($params); 31 | $this->assertEquals($expected, $result); 32 | } 33 | 34 | public function dataProviderPrepareParameters() 35 | { 36 | return array( 37 | array( 38 | array( 39 | 'dbname' => 'fake-db', 40 | 'user' => 'fake-user', 41 | 'password' => 'fake-password', 42 | ), 43 | array( 44 | 'dsn' => 'mysql:host=localhost;port=3306;dbname=fake-db', 45 | 'user' => 'fake-user', 46 | 'password' => 'fake-password', 47 | 'options' => array(), 48 | 'attributes' => array(), 49 | ), 50 | ), 51 | array( 52 | array( 53 | 'host' => '127.0.0.1', 54 | 'port' => null, 55 | 'dbname' => 'fake-db', 56 | 'user' => 'fake-user', 57 | 'password' => 'fake-password', 58 | ), 59 | array( 60 | 'dsn' => 'mysql:host=127.0.0.1;dbname=fake-db', 61 | 'user' => 'fake-user', 62 | 'password' => 'fake-password', 63 | 'options' => array(), 64 | 'attributes' => array(), 65 | ), 66 | ), 67 | array( 68 | array( 69 | 'unix_socket' => '/var/run/mysqld/mysqld.sock', 70 | 'dbname' => 'fake-db', 71 | 'user' => 'fake-user', 72 | 'password' => 'fake-password', 73 | ), 74 | array( 75 | 'dsn' => 'mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=fake-db', 76 | 'user' => 'fake-user', 77 | 'password' => 'fake-password', 78 | 'options' => array(), 79 | 'attributes' => array(), 80 | ), 81 | ), 82 | array( 83 | array( 84 | 'unix_socket' => '/var/run/mysqld/mysqld.sock', 85 | 'dbname' => 'fake-db', 86 | 'user' => 'fake-user', 87 | 'password' => 'fake-password', 88 | 'attributes' => array( 89 | \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" 90 | ), 91 | ), 92 | array( 93 | 'dsn' => 'mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=fake-db', 94 | 'user' => 'fake-user', 95 | 'password' => 'fake-password', 96 | 'options' => array(), 97 | 'attributes' => array( 98 | \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" 99 | ), 100 | ), 101 | ), 102 | ); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /tests/Config/OracleConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class OracleConfigTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var OracleConfig 17 | */ 18 | protected $pdoConfig; 19 | 20 | public function setUp() 21 | { 22 | $this->pdoConfig = new OracleConfig(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderPrepareParameters 27 | */ 28 | public function testPrepareParameters($params, $expected) 29 | { 30 | $result = $this->pdoConfig->prepareParameters($params); 31 | $this->assertEquals($expected, $result); 32 | } 33 | 34 | public function dataProviderPrepareParameters() 35 | { 36 | return array( 37 | array( 38 | array( 39 | 'dbname' => 'fake-db', 40 | 'user' => 'fake-user', 41 | 'password' => 'fake-password', 42 | ), 43 | array( 44 | 'dsn' => 'oci:dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SID=fake-db)))', 45 | 'user' => 'fake-user', 46 | 'password' => 'fake-password', 47 | 'options' => array(), 48 | 'attributes' => array(), 49 | ), 50 | ), 51 | array( 52 | array( 53 | 'host' => '127.0.0.1', 54 | 'port' => null, 55 | 'dbname' => 'fake-db', 56 | 'user' => 'fake-user', 57 | 'password' => 'fake-password', 58 | ), 59 | array( 60 | 'dsn' => 'oci:dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=fake-db)))', 61 | 'user' => 'fake-user', 62 | 'password' => 'fake-password', 63 | 'options' => array(), 64 | 'attributes' => array(), 65 | ), 66 | ), 67 | array( 68 | array( 69 | 'host' => '127.0.0.1', 70 | 'service' => true, 71 | 'port' => 1522, 72 | 'dbname' => 'fake-db', 73 | 'user' => 'fake-user', 74 | 'password' => 'fake-password', 75 | ), 76 | array( 77 | 'dsn' => 'oci:dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1522)))(CONNECT_DATA=(SERVICE_NAME=fake-db)))', 78 | 'user' => 'fake-user', 79 | 'password' => 'fake-password', 80 | 'options' => array(), 81 | 'attributes' => array(), 82 | ), 83 | ), 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /tests/Config/PdoConfigFactoryTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class PdoConfigFactoryTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var PdoConfigFactory 17 | */ 18 | protected $factory; 19 | 20 | public function setUp() 21 | { 22 | $this->factory = new PdoConfigFactory(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderCreateConfig 27 | */ 28 | public function testCreateConfig($params, $expected) 29 | { 30 | $this->assertInstanceOf($expected, $this->factory->createConfig($params['driver'])); 31 | } 32 | 33 | public function dataProviderCreateConfig() 34 | { 35 | return array( 36 | array( 37 | array( 38 | 'driver' => '', 39 | ), 40 | '\Csanquer\Silex\PdoServiceProvider\Config\SqliteConfig', 41 | ), 42 | array( 43 | array( 44 | 'driver' => 'sqlite', 45 | ), 46 | '\Csanquer\Silex\PdoServiceProvider\Config\SqliteConfig', 47 | ), 48 | array( 49 | array( 50 | 'driver' => 'mysql', 51 | ), 52 | '\Csanquer\Silex\PdoServiceProvider\Config\MySqlConfig', 53 | ), 54 | array( 55 | array( 56 | 'driver' => 'pgsql', 57 | ), 58 | '\Csanquer\Silex\PdoServiceProvider\Config\PgSqlConfig', 59 | ), 60 | array( 61 | array( 62 | 'driver' => 'postgre', 63 | ), 64 | '\Csanquer\Silex\PdoServiceProvider\Config\PgSqlConfig', 65 | ), 66 | array( 67 | array( 68 | 'driver' => 'postgresql', 69 | ), 70 | '\Csanquer\Silex\PdoServiceProvider\Config\PgSqlConfig', 71 | ), 72 | array( 73 | array( 74 | 'driver' => 'oci', 75 | ), 76 | '\Csanquer\Silex\PdoServiceProvider\Config\OracleConfig', 77 | ), 78 | array( 79 | array( 80 | 'driver' => 'oracle', 81 | ), 82 | '\Csanquer\Silex\PdoServiceProvider\Config\OracleConfig', 83 | ), 84 | array( 85 | array( 86 | 'driver' => 'sqlsrv', 87 | ), 88 | '\Csanquer\Silex\PdoServiceProvider\Config\SqlSrvConfig', 89 | ), 90 | array( 91 | array( 92 | 'driver' => 'sqlserver', 93 | ), 94 | '\Csanquer\Silex\PdoServiceProvider\Config\SqlSrvConfig', 95 | ), 96 | array( 97 | array( 98 | 'driver' => 'mssqlserver', 99 | ), 100 | '\Csanquer\Silex\PdoServiceProvider\Config\SqlSrvConfig', 101 | ), 102 | array( 103 | array( 104 | 'driver' => 'mssql', 105 | ), 106 | '\Csanquer\Silex\PdoServiceProvider\Config\SqlSrvConfig', 107 | ), 108 | array( 109 | array( 110 | 'driver' => 'dblib', 111 | ), 112 | '\Csanquer\Silex\PdoServiceProvider\Config\DBlibConfig', 113 | ), 114 | ); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /tests/Config/PgSqlConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class PgSqlConfigTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var PgSqlConfig 17 | */ 18 | protected $pdoConfig; 19 | 20 | public function setUp() 21 | { 22 | $this->pdoConfig = new PgSqlConfig(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderPrepareParameters 27 | */ 28 | public function testPrepareParameters($params, $expected) 29 | { 30 | $result = $this->pdoConfig->prepareParameters($params); 31 | $this->assertEquals($expected, $result); 32 | } 33 | 34 | public function dataProviderPrepareParameters() 35 | { 36 | return array( 37 | array( 38 | array( 39 | 'dbname' => 'fake-db', 40 | 'user' => 'fake-user', 41 | 'password' => 'fake-password', 42 | ), 43 | array( 44 | 'dsn' => 'pgsql:host=localhost;port=5432;dbname=fake-db', 45 | 'user' => 'fake-user', 46 | 'password' => 'fake-password', 47 | 'options' => array(), 48 | 'attributes' => array(), 49 | ), 50 | ), 51 | array( 52 | array( 53 | 'host' => '127.0.0.1', 54 | 'port' => null, 55 | 'dbname' => 'fake-db', 56 | 'user' => 'fake-user', 57 | 'password' => 'fake-password', 58 | ), 59 | array( 60 | 'dsn' => 'pgsql:host=127.0.0.1;dbname=fake-db', 61 | 'user' => 'fake-user', 62 | 'password' => 'fake-password', 63 | 'options' => array(), 64 | 'attributes' => array(), 65 | ), 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /tests/Config/SqlSrvConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class SqlSrvConfigTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var SqlSrvConfig 17 | */ 18 | protected $pdoConfig; 19 | 20 | public function setUp() 21 | { 22 | $this->pdoConfig = new SqlSrvConfig(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderPrepareParameters 27 | */ 28 | public function testPrepareParameters($params, $expected) 29 | { 30 | $result = $this->pdoConfig->prepareParameters($params); 31 | $this->assertEquals($expected, $result); 32 | } 33 | 34 | public function dataProviderPrepareParameters() 35 | { 36 | return array( 37 | array( 38 | array( 39 | 'dbname' => 'fake-db', 40 | 'user' => 'fake-user', 41 | 'password' => 'fake-password', 42 | ), 43 | array( 44 | 'dsn' => 'sqlsrv:port=1433;dbname=fake-db;server=localhost', 45 | 'user' => 'fake-user', 46 | 'password' => 'fake-password', 47 | 'options' => array(), 48 | 'attributes' => array(), 49 | ), 50 | ), 51 | array( 52 | array( 53 | 'host' => '127.0.0.1', 54 | 'port' => null, 55 | 'dbname' => 'fake-db', 56 | 'user' => 'fake-user', 57 | 'password' => 'fake-password', 58 | 'attributes' => array(), 59 | ), 60 | array( 61 | 'dsn' => 'sqlsrv:dbname=fake-db;server=127.0.0.1', 62 | 'user' => 'fake-user', 63 | 'password' => 'fake-password', 64 | 'options' => array(), 65 | 'attributes' => array(), 66 | ), 67 | ), 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tests/Config/SqliteConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | */ 13 | class SqliteConfigTest extends \PHPUnit_Framework_TestCase 14 | { 15 | /** 16 | * @var SqliteConfig 17 | */ 18 | protected $pdoConfig; 19 | 20 | public function setUp() 21 | { 22 | $this->pdoConfig = new SqliteConfig(); 23 | } 24 | 25 | /** 26 | * @dataProvider dataProviderPrepareParameters 27 | */ 28 | public function testPrepareParameters($params, $expected) 29 | { 30 | $result = $this->pdoConfig->prepareParameters($params); 31 | $this->assertEquals($expected, $result); 32 | } 33 | 34 | public function dataProviderPrepareParameters() 35 | { 36 | return array( 37 | array( 38 | array( 39 | ), 40 | array( 41 | 'dsn' => 'sqlite::memory:', 42 | 'options' => array(), 43 | 'attributes' => array(), 44 | ), 45 | ), 46 | array( 47 | array( 48 | 'path' => 'memory', 49 | ), 50 | array( 51 | 'dsn' => 'sqlite::memory:', 52 | 'options' => array(), 53 | 'attributes' => array(), 54 | ), 55 | ), 56 | array( 57 | array( 58 | 'path' => 'var/db/db.sq3', 59 | ), 60 | array( 61 | 'dsn' => 'sqlite:var/db/db.sq3', 62 | 'options' => array(), 63 | 'attributes' => array(), 64 | ), 65 | ), 66 | ); 67 | } 68 | 69 | /** 70 | * @dataProvider dataProviderConnect 71 | */ 72 | public function testConnect($params) 73 | { 74 | if (!in_array('sqlite', \PDO::getAvailableDrivers())) { 75 | $this->markTestSkipped('pdo_sqlite is not available'); 76 | } 77 | 78 | $pdo = $this->pdoConfig->connect($params); 79 | $this->assertInstanceOf('\PDO', $pdo); 80 | } 81 | 82 | public function dataProviderConnect() 83 | { 84 | return array( 85 | array( 86 | array( 87 | ), 88 | ), 89 | ); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /tests/Provider/PDOServiceProviderTest.php: -------------------------------------------------------------------------------- 1 | 12 | * 13 | */ 14 | class PDOServiceProviderTest extends \PHPUnit_Framework_TestCase 15 | { 16 | 17 | /** 18 | * @dataProvider providerConnection 19 | */ 20 | public function testConnection($prefix, $server = array(), $options = array(), $attributes = array(), $expectedServer = array(), $expectedOptions = array(), $expectedAttributes = array()) 21 | { 22 | if (!in_array('sqlite', \PDO::getAvailableDrivers())) { 23 | $this->markTestSkipped('pdo_sqlite is not available'); 24 | } 25 | 26 | if (empty($prefix)) { 27 | $this->setExpectedException('InvalidArgumentException', 'The specified prefix is not valid.'); 28 | } 29 | 30 | $app = new Application(); 31 | $app->register(new PDOServiceProvider($prefix), array( 32 | $prefix.'.server' => $server, 33 | $prefix.'.options' => $options, 34 | $prefix.'.attributes' => $attributes, 35 | )); 36 | 37 | $this->assertInstanceOf('\PDO', $app[$prefix]); 38 | $this->assertEquals($expectedServer, $app[$prefix.'.server']); 39 | $this->assertEquals($expectedOptions, $app[$prefix.'.options']); 40 | $this->assertEquals($expectedAttributes, $app[$prefix.'.attributes']); 41 | } 42 | 43 | public function testRegistrationDoesNotOverwriteConfig() 44 | { 45 | $pdoMock = $this->getMock( 46 | '\\Csanquer\\Silex\\PdoServiceProvider\\Provider\\PDOServiceProvider', 47 | array('getPdo'), 48 | array('test_pdo') 49 | ); 50 | $pdoMock->expects($this->once())->method('getPdo'); 51 | $config = $this->getTestConfig(); 52 | $app = new Application($config); 53 | $app->register($pdoMock); 54 | foreach ($config as $key => $value) { 55 | $this->assertSame($value, $app[$key]); 56 | } 57 | } 58 | 59 | protected function getTestConfig() 60 | { 61 | return array( 62 | 'test_pdo.server' => array( 63 | // PDO driver to use among : mysql, pgsql , oracle, mssql, sqlite, dblib 64 | 'driver' => 'mysql', 65 | 'host' => 'mock_host', 66 | 'dbname' => 'mock_db', 67 | 'port' => 3306, 68 | 'user' => 'mock_user', 69 | 'password' => 'mock_password', 70 | ), 71 | // optional PDO attributes used in PDO constructor 4th argument driver_options 72 | // some PDO attributes can be used only as PDO driver_options 73 | // see http://www.php.net/manual/fr/pdo.construct.php 74 | 'test_pdo.options' => array( 75 | \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" 76 | ), 77 | // optional PDO attributes set with PDO::setAttribute 78 | // see http://www.php.net/manual/fr/pdo.setattribute.php 79 | 'test_pdo.attributes' => array( 80 | \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, 81 | ), 82 | ); 83 | } 84 | 85 | public function providerConnection() 86 | { 87 | return array( 88 | array( 89 | null, 90 | ), 91 | array( 92 | 'pdo', 93 | array(), 94 | array(), 95 | array(), 96 | array('driver' => 'sqlite'), 97 | ), 98 | array( 99 | 'foo', 100 | array('driver' => 'sqlite', 'path' => 'memory'), 101 | array(), 102 | array( 103 | \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, 104 | ), 105 | array('driver' => 'sqlite', 'path' => 'memory'), 106 | array(), 107 | array( 108 | \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, 109 | ), 110 | ), 111 | ); 112 | } 113 | } 114 | --------------------------------------------------------------------------------