jeffersongoncalves/laravel-cep
Laravel package to fetch and validate Brazilian CEP (postal code) data in your app. Provides simple helpers/service to query CEP information and integrate with forms and address lookups, with easy configuration and straightforward usage.
config/cep.php for provider settings).guzzlehttp/guzzle for HTTP calls), reducing version conflicts.$address = Cep::find('01001000'); // Returns structured address data
config/cep.php).CepServiceProvider or service bindings.User has addressable relationship).composer require jeffersongoncalves/laravel-cep
php artisan vendor:publish --provider="JeffersonGoncalves\LaravelCep\CepServiceProvider"
config/cep.php:
'providers' => [
'viacep' => [
'enabled' => true,
'api_url' => env('VIA_CEP_API_URL', 'https://viacep.com.br/ws/'),
],
],
Cep facade or bind the service in AppServiceProvider:
$this->app->bind('cep', function ($app) {
return new \JeffersonGoncalves\LaravelCep\CepManager($app['config']['cep']);
});
$address = Cep::find('01001000');
composer.json for exact range).php -v).composer outdated) and provider API changes.try {
$address = Cep::find('invalid_cep');
} catch (\JeffersonGoncalves\LaravelCep\Exceptions\CepNotFoundException $e) {
Log::warning("CEP not found: {$e->getCep()}");
}
spatie/rate-limiter).Cep::findMany()).$address = Cache::remember("cep_{$cep}", now()->addHours(1), function () use ($cep) {
return Cep::find($cep);
});
cep_cache table.| Failure | Impact | Mitigation |
|---|---|---|
| Provider API downtime | Address data unavailability | Fallback providers + retry logic |
| Invalid CEP input | Application errors | Validate input (e.g., regex ^\d{5}-\d{3}$) |
| Rate limit exceeded | Throttled requests | Queue jobs + exponential backoff |
| Stale cached data | Outdated addresses | Short TTL + cache invalidation |
| Provider API changes | Broken functionality | Feature flags for provider switching |
How can I help you explore Laravel packages today?