diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6c224e0..0000000 --- a/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -# Cache and logs (Symfony2) -/app/cache/* -/app/logs/* -!app/cache/.gitkeep -!app/logs/.gitkeep - -# Email spool folder -/app/spool/* - -# Cache, session files and logs (Symfony3) -/var/cache/* -/var/logs/* -/var/sessions/* -!var/cache/.gitkeep -!var/logs/.gitkeep -!var/sessions/.gitkeep - -# Parameters -/app/config/parameters.yml -/app/config/parameters.ini - -# Managed by Composer -/app/bootstrap.php.cache -/var/bootstrap.php.cache -/bin/* -!bin/console -!bin/symfony_requirements - -# Assets and user uploads -/web/bundles/ -/web/uploads/ - -# PHPUnit -/app/phpunit.xml -/phpunit.xml - -# Build data -/build/ - -# Backup entities generated with doctrine:generate:entities command -**/Entity/*~ diff --git a/DependencyInjection/ApiPostcodeExtension.php b/DependencyInjection/ApiPostcodeExtension.php index c0aa41b..4e4a3a8 100644 --- a/DependencyInjection/ApiPostcodeExtension.php +++ b/DependencyInjection/ApiPostcodeExtension.php @@ -28,7 +28,7 @@ public function load(array $configs, ContainerBuilder $container) $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $container->setParameter('postcode_api_key', $config['api_postcode']['token']); + $container->setParameter('api_postcode_key', $config['token']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 69bc069..cb1f824 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -23,13 +23,11 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('api_postcode'); + $treeBuilder = new TreeBuilder('api_postcode'); + $rootNode = $treeBuilder->getRootNode(); $rootNode->children() - ->arrayNode('api_postcode')->isRequired()->children() ->scalarNode('token')->isRequired()->end() - ->end() ->end(); return $treeBuilder; diff --git a/README.md b/README.md index abdb7a4..1b3b671 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,69 @@ -# api-postcode-bundle -Symfony Bundle for fetching Address details +Api Postcode Bundle +=================== + +This bundle can be useed to fetch Address details from zipcode with number. + +See: https://api-postcode.nl for more information. + +Installation +------------ +Installation is a quick 3 step process: + +1. Download api-postcode-bundle using composer +2. Enable the Bundle in AppKernel.php +3. Configure Api Postcode credentials + +### Step 1: Download postcode-bundle using composer + +Add ApiPostcodeBundle by running the command: + +``` bash +$ composer require api-postcode/api-postcode-bundle +``` + +### Step 2: Enable the Bundle in AppKernel.php + + +``` php +get('api.postcode')->fetchAddress('1012JS', 1); + +$address->getStreet(); // Dam +$address->getCity(); // Amsterdam +$address->getHouseNumber(); // 1 +$address->getZipCode(); // 1012JS +$address->getLongitude(); // 4.4584 +$address->getLatitude(); // 52.2296 +``` + +Usage from API +-------------- + +Or try the API response: + +http://127.0.0.1:8000/api/postcode?postcode=2011WD&nummer=2 diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 1b2cfd3..b2287e6 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -1,5 +1,8 @@ services: - api.postcode.client: - class: ApiPostcode\Client + api.postcode: + class: ApiPostcode\Client\PostcodeClient arguments: - - "%postcode_api_key%" + - "%api_postcode_key%" + + ApiPostcode\Client\PostcodeClient: + alias: api.postcode diff --git a/composer.json b/composer.json index 6ee80b5..fe77191 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,13 @@ } ], "require": { - "php": ">=5.4", - "symfony/framework-bundle": "^2.7 || ^3.0", + "php": ">=7.1.0", + "ext-json": "*", + "symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", "api-postcode/php-client": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^6.0", - "matthiasnoback/symfony-dependency-injection-test": "^2.0" + "phpunit/phpunit": "^6.0" }, "autoload": { "psr-4": {