infanatica/infanatica-cep-module

基于Zend Framework 2的通过CEP查询地址的模块

v1.0 2015-02-12 22:38 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:50:57 UTC


README

Latest Stable Version Total Downloads Build Status Code Climate

InfanaticaCepModule

基于Zend Framework 2的通过CEP查询地址的模块

安装

通过克隆安装

在您的Zend Framework 2项目中的"./vendor"或"./module"文件夹中克隆项目InfanaticaCepModule

    $ cd PASTA_DO_SKELETON_DO_ZEND_FRAMEWORK2
    $ cd vendor
    $ git clone https://github.com/Infanatica/InfanaticaCepModule.git

通过composer安装

方法1

将项目InfanaticaCepModule添加到您的composer.json文件中

    "require": {
        "infanatica/infanatica-cep-module": "dev-master"
    }

执行composer的"update"或"install"命令以下载InfanaticaCepModule

    $ php composer.phar update
方法2

执行composer的"require"命令以更新您的composer.json并下载InfanaticaCepModule

	php composer.phar require infanatica/infanatica-cep-module dev-master

安装后

将其添加到您的application.config.php文件中

    <?php
    return array(
        'modules' => array(
            // ...
            'InfanaticaCepModule',
        ),
        // ...
    );

服务使用

示例在\Application\Controller\InderController中

	<?php
	//...
	class IndexController extends AbstractActionController
	{
		public function indexAction()
	    {
			$cep = '21041020';

			// Possíveis formatos (json, xml, query, object, array)
			// null = \InfanaticaCepModule\Response\EnderecoResponse
			$formato        = 'json';

			$serviceLocator = $this->getServiceLocator();
			$cepService     = $serviceLocator->get('InfanaticaCepModule\Service\CepService');
			$endereco       = $cepService->getEnderecoByCep($cep,$formato);
			var_dump($endereco);

	        return new ViewModel();
	    }
    //...

控制器使用

路由示例

\InfanaticaCepModule\Controller\CepController

http[s]://domain/cep/CEP编号

http[s]://domain/cep/21041020

http[s]://domain/cep/CEP编号/输出格式

http[s]://domain/cep/21041020/json

http[s]://domain/cep/21041020/xml

CEP搜索适配器参考

ViaCEP (已完成)

Postmon (已完成)

Correio Control (已完成)

Republica Virtual (已完成)

贡献者

Diogo Oliveira Mascarenhas (https://github.com/diogomascarenha)

Everton Muniz (https://github.com/munizeverton)