PHPackages                             thedevsaddam/world-countries - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. thedevsaddam/world-countries

ActivePackage[Utility &amp; Helpers](/categories/utility)

thedevsaddam/world-countries
============================

Provide world country list with country code, city, states and flag

1.1(9y ago)213465[3 issues](https://github.com/thedevsaddam/world-countries/issues)MITPHP

Since Aug 30Pushed 9y ago2 watchersCompare

[ Source](https://github.com/thedevsaddam/world-countries)[ Packagist](https://packagist.org/packages/thedevsaddam/world-countries)[ Docs](https://github.com/thedevsaddam/world-countries)[ RSS](/packages/thedevsaddam-world-countries/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (3)Used By (0)

World Countries
===============

[](#world-countries)

This package contains world country list along with states, cities, country code and country flags.

---

Installation
------------

[](#installation)

Via Composer

```
$ composer require thedevsaddam/world-countries
```

Install manually (add the line to composer.json file)

```
"thedevsaddam/world-countries": "1.1"
```

Open your terminal and hit the command

```
composer update
```

Add the following line to config/app.php file

```
Thedevsaddam\WorldCountries\WorldCountriesServiceProvider::class,
```

To publish the configuration and resources

```
php artisan vendor:publish
```

###### ***If you need only flags then avoid the command below. The command will required when you are going to use countries with states, cities, country code etc***

[](#if-you-need-only-flags-then-avoid-the-command-below-the-command-will-required-when-you-are-going-to-use-countries-with-states-cities-country-code-etc)

```
php artisan world-countries:populate
```

The above command will populate the countries and other tables to database

To drop the populated tables

```
php artisan world-countries:drop
```

### **Features**

[](#features)

1. World country list with Official name, short name, flag, latitude, longitude.
2. World country list with states and cities
3. World Timezones (coming soon)

### **Usage**

[](#usage)

To fetch all the countries with flag. This will return a collection object so that you can use the available method of Collection class

```
WorldCountries::getCountriesWithFlag();
```

##### Example

[](#example)

```
$countries = WorldCountries::getCountriesWithFlag();
foreach($countries as $key => $country){
    echo "";
    echo $country['name'];
    echo "";
}
// you can use all the method of Collection class

$country = WorldCountries::getCountriesWithFlag()->where('name', 'Bangladesh');
```

#### Fetch all the countries with state and cities

[](#fetch-all-the-countries-with--state-and-cities)

```
$countries = WorldCountries::getCountriesWithStateCity();

//Note: This query will take some time to fetch all the countries with its associate states and cities
```

#### Get Eloquent model to perform custom query

[](#get-eloquent-model-to-perform-custom-query)

```
$countryModel = WorldCountries::getCountryModel();

//Fetch all the countries in array
$countries = $countryModel->get()->toArray();

//Fetch all the countries with states
$countriesWithStates = $countryModel->with('states')->get();

//Note: you can use Laravel eloquent available methods (See the below example)

$countryModel = WorldCountries::getCountryModel();
$country = $countryModel->where('name', 'Bangladesh')->first();
```

Note: You can get city and state model as well. To get them use the methods below

```
$stateModel = WorldCountries::getStateModel();
$cityModel = WorldCountries::getCityModel();
//now you can perform any query available to Eloquent model
```

###### Best uses of this package is to populate dropdown with countries.

[](#best-uses-of-this-package-is-to-populate-dropdown-with-countries)

```
//first get all the countries and populate the country dropdown
$countryModel = WorldCountries::getCountryModel();
$countries = $countryModel->lists('name', 'id');

//you can make an endpoint to fetch all the states against some individual country
$stateModel = WorldCountries::getStateModel();
$states = $stateModel->where('country_id', $someRequest->countryId)->get()->toArray();
return response()-json($states);

// now make another endpoint against the state and fetch all of it's cities.
$cityModel = WorldCountries::getCityModel();
$cities = $cityModel->where('state_id', $someRequest->stateId)->get()->toArray();
return response()->json($cities);
```

##### Config

[](#config)

If you change the flag directory name or path then update the config/flag.php file\_path according to the path name

##### Credit

[](#credit)

###### Flag and country list json from: [cristiroma](https://github.com/cristiroma/countries)

[](#flag-and-country-list-json-from-cristiroma)

###### Countries, state and cities mysql dump from: [cristiroma](https://github.com/cristiroma/countries)

[](#countries-state-and-cities-mysql-dump-from-cristiroma)

Thank you :)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3590d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9676798?v=4)[Saddam H](/maintainers/thedevsaddam)[@thedevsaddam](https://github.com/thedevsaddam)

---

Top Contributors

[![thedevsaddam](https://avatars.githubusercontent.com/u/9676798?v=4)](https://github.com/thedevsaddam "thedevsaddam (4 commits)")

---

Tags

citycountriesworldcountriesflagworldthedevsaddamworld-citiesworld-flag

### Embed Badge

![Health badge](/badges/thedevsaddam-world-countries/health.svg)

```
[![Health](https://phpackages.com/badges/thedevsaddam-world-countries/health.svg)](https://phpackages.com/packages/thedevsaddam-world-countries)
```

###  Alternatives

[pragmarx/countries

PHP Countries and Currencies

1.9k3.4M22](/packages/pragmarx-countries)[rinvex/countries

Rinvex Countries is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

1.7k7.8M58](/packages/rinvex-countries)[league/iso3166

ISO 3166-1 PHP Library

69937.6M136](/packages/league-iso3166)[stefangabos/world_countries

Constantly updated lists of world countries, territories and areas of geographical interest, with associated alpha-2, alpha-3 and numeric codes as defined by the ISO 3166-1 standard, available in multiple formats and languages, with national flags included

1.6k131.2k1](/packages/stefangabos-world-countries)[webpatser/laravel-countries

Modern Laravel Countries package providing ISO 3166-2, ISO 3166-3, currency, capital and more for all countries. Compatible with Laravel 11.x, 12.x, and 13.x.

8402.8M9](/packages/webpatser-laravel-countries)[pragmarx/countries-laravel

Countries for Laravel

1471.1M2](/packages/pragmarx-countries-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
