PHP code example of lsnepomuceno / laravel-brazilian-ceps
1. Go to this page and download the library: Download lsnepomuceno/laravel-brazilian-ceps 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/ */
lsnepomuceno / laravel-brazilian-ceps example snippets
use LSNepomuceno\LaravelBrazilianCeps\Services\CepService;
class ExampleController() {
// PHP 8: Constructor property promotion
public function __construct(protected CepService $cepService) { }
public function dummyFunction(string|int $cep){
$address = $this->cepService->get($cep);
dd($address);
}
}
use LSNepomuceno\LaravelBrazilianCeps\Services\CepService;
use LSNepomuceno\LaravelBrazilianCeps\Exceptions\CepNotFoundException;
class ExampleController() {
// PHP 8: Constructor property promotion
public function __construct(protected CepService $cepService) { }
public function dummyFunction(string|int $cep){
try {
$address = $this->cepService->get($cep);
dd($address);
} catch(CepNotFoundException $e) {
// TODO necessary
}
}
}