PHP code example of canducci / cep

1. Go to this page and download the library: Download canducci/cep library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

canducci / cep example snippets


   'providers' => [
       ...
       Canducci\Cep\Providers\CepServiceProvider::class
   ]

   

   'aliases' => [
       ...
       'Cep' => Canducci\Cep\Facades\Cep::class,
       'Endereco' => Canducci\Cep\Facades\Endereco::class
   ]

   

   Route::get('/cep', function(\Canducci\Cep\Cep $cep){
       $cepResponse = $cep->find('01010000');
       $data = $cepResponse->getCepModel();
       return response()->json($data);
   });

   Route::get('/endereco', function(\Canducci\Cep\Endereco $endereco){
       $enderecoResponse = $endereco->find('sp','são paulo', 'ave');
       $data = $enderecoResponse->getCepModels();
       return response()->json($data);
   });
   

   Route::get('/cep', function(){
      $cepResponse = \Canducci\Cep\Facades\Cep::find('01010000');
      $data = $cepResponse->getCepModel();
      return response()->json($data);
   });

   Route::get('/endereco', function(){
      $enderecoResponse = \Canducci\Cep\Facades\Endereco::find('sp','são paulo', 'ave');
      $data = $enderecoResponse->getCepModels();
      return response()->json($data);
   });
   

   Route::get('/cep', function(){
      $cepResponse = cep('01010000');
      $data = $cepResponse->getCepModel();
      return response()->json($data);
   });

   Route::get('/endereco', function(){
       $enderecoResponse = endereco('sp','são paulo','ave');
       $data = $enderecoResponse->getCepModels();
       return response()->json($data);
    });
   

   $cepResponse = cep('01010000');
   if ($cepResponse->isOk())
   {
       $data = $cepResponse->getCepModel();
       return response()->json($data);
   }
   

    $model->getCep() ou $model->cep
    $model->getLogradouro() ou $model->logradouro
    $model->getComplemento() ou $model->c omplemento
    $model->getBairro() ou $model->bairro
    $model->getLocalidade() ou $m odel->localidade
    $model->getUf() ou $model->uf
    $model->getDdd() ou $model->ddd
    $model->getSiafi() ou $model->sia fi
    $model->getIbge() ou $model->ib   ge
    $model->getGia() ou $model->gia
   



  esponse = cep('01010000');
  $data = $cepResponse->getCepModel();
  echo json_encode($data);

λ php composer.phar