krunalvat/location-dropdowns
Composer 安装命令:
composer require krunalvat/location-dropdowns
包简介
A Laravel package for Country, State, and City location dropdowns.
README 文档
README
A beautiful, lightweight, and automated Laravel package to sync and manage global Countries, States, and Cities in your database.
Perfect for marketing teams, e-commerce checkouts, and SaaS platforms that need reliable location dropdowns with zero manual data entry!
Features ✨
- Automated Sync: A powerful Artisan command that instantly downloads and updates thousands of locations from a reliable open-source community database.
- Dynamic Country Flags: Automatically generates and attaches
flagcdnURLs to your API responses, allowing you to display beautiful flags in your frontend UI without bloating your database! - Proxy Flag Images: Built-in proxy routes to serve flags directly from your own domain, perfectly hiding the external CDN from your frontend.
- Fully Normalized Tables: Clean and highly-optimized database architecture (Countries -> States -> Cities).
- API Ready: Comes with fast, built-in JSON API endpoints out-of-the-box.
- Zero Configuration: The data source is securely obfuscated within the codebase, requiring no messy
.envsetups to get started.
Installation 🚀
You can install the package via composer:
composer require krunalvat/location-dropdowns
Getting Started
- Publish the Migrations & Config (Optional)
php artisan vendor:publish --tag="location-migrations" php artisan vendor:publish --tag="location-config"
- Run the Migrations Create the necessary tables in your database:
php artisan migrate
- Sync the Data! Run the automated sync command to populate your database with the latest global location data:
php artisan locations:sync
Usage 💻
Once synced, your application will immediately have access to three new API routes:
GET /api/locations/countries(Returns all countries with dynamic flag URLs attached!)GET /api/locations/states/{country_id}GET /api/locations/cities/{state_id}
Example Frontend Response
{
"id": 101,
"name": "India",
"iso2": "IN",
"phonecode": "91",
"flag_url": "http://yourdomain.com/api/locations/flags/in"
}
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-16