Download the PHP package imujas9/laravel-world without Composer

On this page you can find all versions of the php package imujas9/laravel-world. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-world

๐ŸŒ Laravel World

Latest Version on Packagist Total Downloads PHP Version

World countries, states, and cities for Laravel โ€” with multi-language support. Works without a database out of the box. Switch to a database driver any time with a single env variable.


โœจ What Makes This Different

Feature Laravel World Others
Works without a database โœ… โŒ
Switch to DB with one env var โœ… โŒ
Auto locale detection โœ… โŒ
Multi-language in one query โœ… โŒ
City translations on demand โœ… โŒ
20+ languages for countries & states โœ… Partial
Fluent chainable API โœ… Limited
Partial name search & operators โœ… โŒ

๐Ÿ“ฆ What's Included


Requirements & Installation

No migrations, no seeding, no config. Auto-registers and works immediately.


Quick Start


โš™๏ธ Configuration

๐ŸŒ Locale Support The package reads `app()->getLocale()` automatically. No `lang()` call needed once locale is set in middleware. **Resolution order** (when `lang()` is not called): 1. `app()->getLocale()` โ€” set by middleware or `App::setLocale()` 2. `config('world.default_lang')` โ€” `WORLD_LANG` env value 3. `'en'` โ€” hardcoded fallback Locale strings are normalised: `en_US` โ†’ `en`, `zh_CN` โ†’ `zh`. **Middleware example:** **Fallback behaviour:** | Locale | Translation file exists | Result | | ------- | ----------------------- | ---------------------------- | | `hi` | โœ… | Hindi name | | `ga` | โŒ | Falls back to `default_lang` | | `en_US` | โœ… normalised to `en` | English name | `lang()` always overrides the locale for that specific query.

๐Ÿ™๏ธ City Translations City names work in English out of the box. Translations are **not bundled** (they add 51 MB to every install) โ€” download only what you need: Once downloaded, translations are used automatically: **Available:** `ar` `bn` `br` `de` `es` `fa` `fr` `ga` `hi` `hr` `hy` `id` `it` `ja` `ko` `nl` `pl` `pt` `ru` `tr` `uk` `ur` `vi` `zh` > Add `php artisan world:translations hi` to your deploy script for the languages your app uses.

๐Ÿ—„๏ธ Database Driver Use the database driver when you need SQL joins, full-text search, or indexing on millions of rows. > Re-seed: `php artisan world:seed --truncate` Your application code stays **exactly the same** โ€” the driver swap is transparent. **When to use each driver:** | Scenario | Recommended driver | | -------------------------------------------------- | ------------------ | | Read-only lookups, dropdowns, country picker | `file` (default) | | SQL `JOIN` to your own tables | `database` | | Full-text search with relevance ranking | `database` | | Multi-tenant SaaS โ€” no shared DB schema constraint | `file` | | High-traffic API โ€” want to avoid repeated JSON I/O | `file` + cache | | You already manage a world-data migration workflow | `database` | **DB performance notes:** - `paginate()` runs a `COUNT(*)` + a single `LIMIT/OFFSET` query โ€” no full table scan. - An index on `name` is created for all three tables. Use `whereLike('name', 'Ind%')` for fast prefix searches. - For suffix / infix LIKE (`%istan%`), consider a full-text index on your database engine.

๐Ÿ“– API Reference ### Country ### State ### City

๐Ÿ“Š Result Objects All methods return consistent value objects regardless of driver. ### CountryData | Property | Type | Description | | ------------ | -------------- | ------------------------------------------------- | | `id` | `int` | Numeric ID | | `code` | `string` | ISO2 (e.g. `IN`) | | `iso3` | `string` | ISO3 (e.g. `IND`) | | `phone_code` | `string` | Dialling code (e.g. `91`) | | `currency` | `string` | ISO 4217 (e.g. `INR`) | | `flag` | `string\|null` | Emoji flag (e.g. `๐Ÿ‡ฎ๐Ÿ‡ณ`) | | `region` | `string\|null` | e.g. `Asia` | | `subregion` | `string\|null` | e.g. `Southern Asia` | | `capital` | `string\|null` | Capital city (e.g. `New Delhi`) | | `tld` | `string\|null` | Top-level domain (e.g. `.in`) | | `latitude` | `string\|null` | Country centre latitude | | `longitude` | `string\|null` | Country centre longitude | | `name` | `string\|null` | Translated name (single lang) | | `names` | `array` | `['en' => 'India', 'hi' => 'เคญเคพเคฐเคค']` (multi-lang) | ### StateData | Property | Type | Description | | -------------- | -------------- | ----------------------------- | | `id` | `int` | Numeric ID | | `code` | `string` | State code | | `country_code` | `string` | Parent country ISO2 | | `country_id` | `int` | Parent country numeric ID | | `type` | `string\|null` | State / Province / Regionโ€ฆ | | `latitude` | `string\|null` | | | `longitude` | `string\|null` | | | `name` | `string\|null` | Translated name (single lang) | | `names` | `array` | Translated names (multi-lang) | ### CityData | Property | Type | Description | | -------------- | ----------- | ----------------------------------------------- | | `id` | `int` | Numeric ID | | `state_code` | `string` | Parent state code | | `country_code` | `string` | Parent country ISO2 | | `state_id` | `int\|null` | Parent state numeric ID (DB driver only) | | `country_id` | `int\|null` | Parent country numeric ID (DB driver only) | | `latitude` | `string\|null` | | | `longitude` | `string\|null` | | | `name` | `string\|null` | Translated name (single lang) | | `names` | `array` | Translated names (multi-lang) |

๐Ÿ” Filtering & Search All three facades share the same fluent filtering API. ### Equality (default) ### Comparison operators ### LIKE / partial match ### whereIn ### Chaining multiple filters > **File driver note:** LIKE filtering on `name` for countries and states matches the > translated name in the active language. For cities the stored English name is used. > All other fields (`code`, `capital`, `region`, `currency`, etc.) are matched against > the raw data.

๐Ÿ“„ Pagination `paginate()` behaves like Laravel's native paginator โ€” it reads the current page from the `?page` query parameter automatically. The returned `LengthAwarePaginator` carries the correct `path` and query string, so `$countries->links()` renders proper next/prev URLs in Blade templates. **Database driver:** paginate executes a `COUNT(*)` query + a single `LIMIT/OFFSET` data query โ€” no full table scan. **File driver:** paginate streams/filters all matching records to count, then returns only the requested page slice.

๐ŸŒ Available Languages > Missing translations fall back to the English name automatically. > City translations must be downloaded separately โ€” see [City Translations](#๏ธ-city-translations). | Code | Language | Countries | States | Cities | | ---- | -------------------- | --------- | ------ | ------ | | `en` | English | โœ… | โœ… | โœ… | | `ar` | Arabic | โœ… | โœ… | โœ… | | `bn` | Bengali | โŒ | โœ… | โœ… | | `br` | Breton | โœ… | โœ… | โœ… | | `de` | German | โœ… | โœ… | โœ… | | `el` | Greek | โŒ | โœ… | โŒ | | `es` | Spanish | โœ… | โœ… | โœ… | | `et` | Estonian | โŒ | โœ… | โŒ | | `fa` | Persian | โœ… | โœ… | โœ… | | `fi` | Finnish | โŒ | โœ… | โŒ | | `fr` | French | โœ… | โœ… | โœ… | | `ga` | Irish | โŒ | โŒ | โœ… | | `gu` | Gujarati | โœ… | โœ… | โŒ | | `hi` | Hindi | โœ… | โœ… | โœ… | | `hr` | Croatian | โœ… | โœ… | โœ… | | `hy` | Armenian | โŒ | โœ… | โœ… | | `id` | Indonesian | โŒ | โœ… | โœ… | | `it` | Italian | โœ… | โœ… | โœ… | | `ja` | Japanese | โœ… | โœ… | โœ… | | `ko` | Korean | โœ… | โœ… | โœ… | | `nl` | Dutch | โœ… | โœ… | โœ… | | `pl` | Polish | โœ… | โœ… | โœ… | | `pt` | Portuguese | โœ… | โœ… | โœ… | | `ru` | Russian | โœ… | โœ… | โœ… | | `tr` | Turkish | โœ… | โœ… | โœ… | | `uk` | Ukrainian | โœ… | โœ… | โœ… | | `ur` | Urdu | โŒ | โŒ | โœ… | | `vi` | Vietnamese | โŒ | โœ… | โœ… | | `zh` | Chinese (Simplified) | โœ… | โœ… | โœ… |

๐Ÿ”— Model Traits Drop a trait into any Eloquent model to get `country`, `state`, and `city` accessors that work with both drivers. ### HasWorldRelations โ€” all in one ### Individual traits | Trait | Column needed | Type | | ------------ | ------------- | -------------------- | | `HasCountry` | `country_id` | `unsignedBigInteger` | | `HasState` | `state_id` | `unsignedBigInteger` | | `HasCity` | `city_id` | `unsignedBigInteger` | ### Using string codes instead of integer IDs ### Driver behaviour | | File driver | Database driver | | ----------------------- | ---------------- | ------------------------------ | | `$user->country` | โœ… `CountryData` | โœ… `CountryData` | | `User::with('country')` | โŒ no DB table | โœ… eager loads โ†’ `CountryData` |

๐Ÿ› ๏ธ Contributing Contributions, bug reports, and feature requests are welcome. 1. Fork the repo ยท create a branch ยท write tests ยท open a PR **Updating world data** โ€” all data lives in `resources/data/` as plain JSON: | File | Purpose | | ------------------------------------ | ------------------------------------------ | | `countries.json` | Country base data | | `states.json` | State base data | | `cities.json` | City base data | | `translations/countries/{lang}.json` | Country names per language | | `translations/states/{lang}.json` | State names per language | | `translations/cities/{lang}.json` | City names per language (keyed by city ID) | To add a new language, create `translations/countries/{lang}.json` with `{ "ISO2": "Name" }` pairs and repeat for states/cities.

About

Hi, I'm Ujas Patel โ€” a Backend Developer (TALL Stack), based in Ahmedabad, India. I built this package because every existing world-data solution for Laravel forces a database setup before you can use even a simple country list. Laravel World works out of the box โ€” and scales to a full database driver when you need it.

Reach out: imujaspatel [at] gmail [dot] com

GitHub X LinkedIn


Support

Need Where to go
๐Ÿ› Bug Open an issue
๐Ÿ’ก Feature request Open an issue
โ“ Question Start a discussion

If this package saved you time, a โญ on GitHub goes a long way.


License

This package is open-source software licensed under the MIT License. Feel free to use, modify, and distribute it according to the terms of the license.


All versions of laravel-world with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package imujas9/laravel-world contains the following files

Loading the files please wait ...