deondazy/realaddressfactory
最新稳定版本:v2.1.0
Composer 安装命令:
composer require deondazy/realaddressfactory
包简介
Fork of nonsapiens/realaddressfactory with Laravel 12 support. Creates real-world street addresses from Google Maps.
README 文档
README
About
Fork Notice: This is a community-maintained fork of nonsapiens/realaddressfactory with Laravel 12 support.
This library creates actual, 100% real addresses with full address details and lat/long coordinates using the Google Maps API. Features include:
- Laravel 12 compatibility
- Faker integration for database seeding
- Address generation via Facade or direct class usage
Installation
Require this package with composer:
composer require deondazy/realaddressfactory --dev
Google Maps API Requirements
Add your API key to .env:
GOOGLE_MAPS_API_KEY=your_api_key_here
Usage
Faker Integration
class UserFactory extends Factory { protected $model = User::class; public function definition(): array { /** @var GoogleAddress $address */ $address = $this->faker->britishAddress(); return [ 'first_name' => $this->faker->firstName(), 'full_address' => $address->getFormattedAddress(), 'latitude' => $address->getCoordinates()->getLatitude(), 'longitude' => $address->getCoordinates()->getLongitude() ]; } }
Facade Usage
use Nonsapiens\RealAddressFactory\RealAddressFactory; // Generate 20 Johannesburg addresses $saAddresses = RealAddressFactory::makeSouthAfrica(20, 'Johannesburg');
Adding New Countries
Update config/realaddress.php:
'brazil' => [ 'cities' => ['Rio de Janeiro', 'São Paulo'] ],
Then use:
$faker->realAddress('Brazil', 'Rio de Janeiro');
Fork Differences from Original
- ✅ Laravel 12 support
- ✅ Updated dependencies (Testbench 10.x, Geocoder 5.x)
- 🔄 Maintains original functionality
- ⚠️ Namespaces remain unchanged for compatibility
Warning
- Google may block excessive API requests
- API usage may incur Google Cloud charges
- Built-in rate limiter configurable in
config/realaddress.php
Maintenance
Current Maintainer
Deon Okonkwo
Original Author
Stuart Steedman - CTO of Sebenza
Contributing
Pull requests welcome! Please open issues for:
- Laravel compatibility updates
- New country/city additions
- Documentation improvements
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-27