zhuzhichao/ip-location-zh
Get Chinese IP location data in PHP and Laravel. Converts an IP address into country, province, city, and ISP details using the bundled offline QQWry database, with a simple API and Laravel service provider for quick setup. No external API calls needed.
This release is additive: v2.4.5 adds Hong Kong, Macao, and Taiwan to the package’s region/territory dataset. There are no indicated breaking changes, so existing country/region lookups, validation rules, and seeded data should continue to work. The main work is to make sure the new entries are available in your application and used consistently.
First steps:
Update the package
composer update vendor/package
Check whether data is seeded or migrated
php artisan migrate
php artisan db:seed --class=RegionSeeder
php artisan config:clear
php artisan cache:clear
Verify the new entries exist
HK, MO, and TW through its usual lookup API, model, or repository.First real use case
HK, MO, and TW pass the same validation path as other regions.Where to look first:
Use the package as the single source of truth for country/region options:
// Example pattern: use the package's repository/model/API
$regions = Region::query()
->orderBy('name')
->get()
->map(fn ($region) => [
'value' => $region->iso_code,
'label' => $region->name,
]);
This avoids a common failure mode: the package adds HK, MO, and TW, but the application still has a hardcoded list that does not include them.
If you validate region codes in form requests, derive the rule from the package rather than maintaining a duplicate list:
use Illuminate\Validation\Rule;
$rules = [
'country' => ['required', Rule::in(Region::pluck('iso_code'))],
];
For performance-sensitive paths, cache the allowed codes and clear that cache during deployment.
The new regions often need explicit business configuration even after the package data is present. Review:
HK, MO, and TW.HKD, MOP, and TWD are common mappings, but confirm your pricing and rounding rules.If your application localizes region names, confirm translations are present for:
zh-HK / en-HKzh-MO / en-MOzh-TW / en-TWWhere possible, use the package’s translated names rather than adding ad hoc labels in Blade templates.
Add a small regression test so future package updates or application changes do not silently drop the new entries:
public function test_new_regions_are_available(): void
{
$this->assertDatabaseHas('regions', ['iso_code' => 'HK']);
$this->assertDatabaseHas('regions', ['iso_code' => 'MO']);
$this->assertDatabaseHas('regions', ['iso_code' => 'TW']);
}
If the package exposes a repository or service instead of a model, assert through that public API.
composer update does not invalidate those caches automatically.HK, MO, and TW to a config array, a validation rule, and a frontend select, the next package release will create drift again.HK, MO, and TW are supported and use the right calling codes and formatting.config/ or model scopes.How can I help you explore Laravel packages today?