Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ip Location Zh Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. Update the package

    composer update vendor/package
    
  2. Check whether data is seeded or migrated

    • If the package ships region data via migrations/seeders, run:
      php artisan migrate
      php artisan db:seed --class=RegionSeeder
      
    • If it loads data from static files/config, clear cached config and application caches:
      php artisan config:clear
      php artisan cache:clear
      
  3. Verify the new entries exist

    • Confirm the package exposes HK, MO, and TW through its usual lookup API, model, or repository.
    • Check both the human-readable names and ISO codes, since many Laravel forms store the code but display the name.
  4. First real use case

    • Add the new regions to checkout/billing/shipping address forms.
    • Use the package’s canonical list instead of hardcoded arrays, e.g. populate a select from the package’s country/region repository.
    • If you validate region codes, make sure HK, MO, and TW pass the same validation path as other regions.

Where to look first:

  • The package README/changelog for the exact region API.
  • Seeders, migrations, or data files that populate the region table.
  • Any application-level validation rules or form requests that enumerate allowed country codes.
  • Shipping, tax, and currency configuration that maps region codes to business rules.

Implementation Patterns

Populate forms from the package, not from static arrays

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.

Validation backed by the package

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.

Checkout, shipping, and tax zones

The new regions often need explicit business configuration even after the package data is present. Review:

  • Shipping zones and carrier availability for HK, MO, and TW.
  • Tax rules and whether your tax provider supports these regions.
  • Currency defaults: HKD, MOP, and TWD are common mappings, but confirm your pricing and rounding rules.
  • Address formats: Hong Kong and Macao do not use postal codes in the same way as many Western countries; Taiwan does. Make postal-code fields conditional if your checkout currently requires them globally.

Localization and display

If your application localizes region names, confirm translations are present for:

  • zh-HK / en-HK
  • zh-MO / en-MO
  • zh-TW / en-TW

Where possible, use the package’s translated names rather than adding ad hoc labels in Blade templates.

Feature tests for the new regions

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.

Gotchas and Tips

  • This is a data update, not just a code update. In many Laravel packages, region data lives in the database. Updating Composer without running seeders or migrations may leave production without the new entries.
  • Clear caches after deploy. Region lists are commonly cached in config, Redis, or application cache. A successful composer update does not invalidate those caches automatically.
  • Distinguish “countries” from “regions/territories.” Hong Kong and Macao are special administrative regions, and Taiwan’s status is politically sensitive. Prefer labels like “Country/Region” or “Territory” in UI copy unless your business requirements say otherwise.
  • Watch naming and sorting behavior. Region names may sort differently depending on whether the package uses English names, local names, or translated names. Test the dropdown ordering and search results.
  • Do not hardcode the new list in multiple places. If you add HK, MO, and TW to a config array, a validation rule, and a frontend select, the next package release will create drift again.
  • Postal code validation needs special handling. Do not make postal code required for Hong Kong or Macao unless your carrier or payment provider explicitly requires it. Taiwan typically does use postal codes.
  • Phone number validation is separate. Adding a region to the package does not automatically make phone validation correct for that region. If you use a phone library, confirm HK, MO, and TW are supported and use the right calling codes and formatting.
  • Currency and tax providers may lag behind. The package can know about a region before your payment, tax, or shipping provider does. Test checkout end-to-end with each new region.
  • Existing records are unaffected. This release does not imply that previously stored addresses, orders, or users need migration. Only new selections and lookups are affected.
  • Check package-specific extension points. If the package allows overriding region data or adding custom entries, prefer that mechanism over modifying vendor files. Vendor changes will be lost on the next Composer update.
  • Debugging tip: if the new regions do not appear, check in this order: Composer lock version, published config/data files, database seed state, application cache, and any local overrides in config/ or model scopes.
  • Deployment sequence: deploy code, run migrations/seeders, clear caches, then verify the form options and validation rules in the target environment. Avoid seeding region data manually in production unless the package documents that as the supported path.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums