2017 © Pedro PelĂĄez
 

symfony-bundle address-bundle

This is a Symfony2 bundle that lets using international mailing address.

image

feft/address-bundle

This is a Symfony2 bundle that lets using international mailing address.

  • Saturday, November 18, 2017
  • by Feft
  • Repository
  • 1 Watchers
  • 3 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SensioLabsInsight, (*1)

Address

International mailing address created in Symfony2. Format examples on [http://www.bitboost.com/ref/international-address-formats.html#Formats][3], (*2)

The code is compatible with php 7.1 and 5.6 versions., (*3)

Installation

Install the library using composer. Add the new line to your composer.json file:, (*4)

{
    "require": {
        "feft/address-bundle": "dev-master"
    }, 
}

Now run the install command., (*5)

$ php composer.phar install

or use Makefile (only if you are using Docker):, (*6)

make composer

PhpUnit

To run unittests use command (only if you are using Docker):, (*7)

make php5.6-phpunit5

Enable the bundle

Enable the bundle in the kernel:, (*8)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new \Feft\AddressBundle\FeftAddressBundle(),
    );
}

Update doctrine schema

$ php app/console doctrine:schema:update --force

CRUD operations

Every entity has CRUD Controller to show/add/edit/delete operation, eg. to manage countries use link like this: http://localhost/address/web/app.php/country/, (*9)

Usage

Simple use:, (*10)

        $factory = new AddressFactory();

        $addressData = array(
            "countryName" => "Poland",
            "countryAlpha2Code" => "PL",
            "countryLocalShortName" => "Polska",
            "localityName" => "Tychy",
            "regionName" => "ƛląskie",
            "streetName" => "Freedom",
            "postalCode" => "43-100",
            "streetNumber" => "20 m. 21",
        );

        $address = $factory->getAddressObject($addressData);

        return array(
            'address' => $address,
        );

For more examples see unit tests folder., (*11)

Controller file:, (*12)

  use Feft\AddressBundle\Entity\Address;
  use Feft\AddressBundle\Entity\Country;
  use Feft\AddressBundle\Entity\Locality;
  use Feft\AddressBundle\Entity\PostalCode;
  use Feft\AddressBundle\Entity\Region;
  use Feft\AddressBundle\Entity\Street;
  use Feft\AddressBundle\Model\PostalValidator\Factory;

  $country = new Country("Poland","PL");
  $country->setLocalShortName("Polska");

  $locality = new Locality();
  $locality->setName("Tychy");

  $region = new Region();
  $region->setName("ƛląskie");
  $locality->setRegion($region);
  $country->addRegion($locality->getRegion());
  $locality->getRegion()->setCountry($country);

  $street = new Street();
  $street->setName("Wolnoƛci");

  $code = new PostalCode();
  $code->setCode("43-100");
  $code->setValidator(Factory::getInstance($code,$country->getCode()));

  $address = new Address();
  $address->setCountry($country);
  $address->setRegion($region);
  $address->setLocality($locality);
  $address->setStreet($street);
  $address->setNumber("20 m. 21");
  $address->setPostalCode($code);

  $codeValidatingResult = $code->validate();

  $options = array("showCountryName" => true);

  return array(
    'address' => $address,
    "options" => $options
  );

Twig file:, (*13)



{{ address_formatter(address,options)|raw }} , (*14)

or inline format: {{ address_inline_formatter(address,options) }} , (*15)

Html result:
Wolnoƛci 20 m. 21
43-100 Tychy
Poland
or inline format: Wolnoƛci 20 m. 21, 43-100 Tychy, Poland, (*16)

Authors

The bundle was created by Piotr PikuƂa. See the list of contributors., (*17)

The Versions

18/11 2017

dev-master

9999999-dev https://github.com/Feft/AddressBundle

This is a Symfony2 bundle that lets using international mailing address.

  Sources   Download

MIT

The Requires

 

validator address post postal

10/09 2016

1.0

1.0.0.0 https://github.com/Feft/AddressBundle

This is a Symfony2 bundle that lets using international mailing address.

  Sources   Download

MIT

The Requires

 

validator address post postal