2017 © Pedro Peláez
 

symfony-bundle correios-bundle

Symfony Bundle with Correios integration

image

mero/correios-bundle

Symfony Bundle with Correios integration

  • Saturday, June 3, 2017
  • by merorafael
  • Repository
  • 1 Watchers
  • 0 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MeroCorreiosBundle

SensioLabsInsight Latest Stable Version Total Downloads License, (*1)

Symfony Bundle with Correios integration, (*2)

Requirements

  • PHP 5.4.9 or above
  • SOAP extension
  • Symfony 2.8 or above

Instalation with composer

  1. Open your project directory;
  2. Run composer require mero/correios-bundle to add MeroCorreiosBundle in your project vendor;
  3. Open my/project/dir/app/AppKernel.php;
  4. Add Mero\Bundle\CorreiosBundle\MeroCorreiosBundle().

Correios Client

This bundle is only alias to use MeroCorreios., (*3)

Service MeroCorreios Class
mero_correios.client Client

Usage example

namespace Acme\Bundle\ApiBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * @Route("/correios")
 */
class CorreiosController extends Controller
{
    /**
     * @Route("/{zipCode}/address", name="search_zipcode")
     */
    public function searchAction(string $zipCode)
    {
        $client = $this->get('mero_correios.client'); // Return the Mero\Correios\Client
        try {
            $address = $client->findAddressByZipCode($zipCode);

            return new JsonResponse([
                'zip_code' => $zipCode,
                'address' => $address->getAddress(),
                'neighborhood' => $address->getNeighborhood(),
                'city' => $address->getCity(),
                'state' => $address->getState(),
            ]);
        } catch (AddressNotFoundException $e) {
            return new JsonResponse([
                'message' => $e->getMessage(),
            ], 404);
        } catch (InvalidZipCodeException $e) {
            return new JsonResponse([
                'message' => $e->getMessage(),
            ], 404);
        }
    }

}

The Versions

03/06 2017

dev-master

9999999-dev https://github.com/merorafael/MeroCorreiosBundle

Symfony Bundle with Correios integration

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony brazil correios sf mero