gabrielmoura/laravel-cep

一个简单的Laravel包,用于获取CEP信息

1.0 2023-12-09 17:57 UTC

This package is auto-updated.

Last update: 2024-09-05 02:12:51 UTC


README

一个综合性的Laravel包,用于从多个提供商获取巴西邮政编码(CEP)信息,提供无缝缓存和灵活性。

特性

  • 多个提供商:集成
  • 智能缓存:使用可选的Redis缓存优化性能。
  • 易于使用:通过容器或外观提供简单接口。
  • 可定制:配置首选提供商。

安装

composer require gabrielmoura/laravel-cep

配置

发布配置文件(可选)

php artisan vendor:publish --provider="Gabrielmoura\LaravelCep\CepServiceProvider"

在您的 config/services.php 中,根据需要调整默认提供商

'cep' => [
   'endpoint' => \Gabrielmoura\LaravelCep\EndpointOption::POSTMON, // Example: Change to your preferred provider
],

强烈建议安装 illuminate/redis 以实现自动缓存。

用法

容器

use Gabrielmoura\LaravelCep\CepService;
$cepData = app(CepService::class)->find('01001000', true); // Enable caching

外观

use Gabrielmoura\LaravelCep\Cep;
$cepData = Cep::find('01001000', true); // Enable caching

兼容性

  • Laravel 10.x

贡献

我们欢迎贡献!请参阅我们的 CONTRIBUTING.md

许可证

Laravel CEP 采用MIT许可证发布。