PHPackages                             wisdom-diala/countrypkg-laravel - 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. wisdom-diala/countrypkg-laravel

ActiveLibrary

wisdom-diala/countrypkg-laravel
===============================

package to fetch all countries and states around the world and store in the database

1.0.7(3y ago)206.2k↓25%8MITPHP

Since Apr 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/wisdom-diala/countrypkg-laravel)[ Packagist](https://packagist.org/packages/wisdom-diala/countrypkg-laravel)[ RSS](/packages/wisdom-diala-countrypkg-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (9)Used By (0)

countrypkg-laravel
==================

[](#countrypkg-laravel)

package to fetch all countries and states around the world and store in the database

IMPORTANCE OF THE PACKAGE
-------------------------

[](#importance-of-the-package)

**NO API CALLS**: Over the years i have been working with many API's that will help in getting countries with their State/Province, Making an API calls to the endpoint everytime a user visits the site, most of the times slow down the site while getting response from the third party website where the API was hosted. This packages eliminates any API calls of any such, you now have all the countries in your local database by running a simple command.

FEATURES
--------

[](#features)

**Generate Countries**: This package helps you to generate countries around the world and save it inside your existing or newly created database without hitting any API endpoint.

**Generate States**: This package helps you to generate states/Province around the world with country ID generated initially when the country table was created. You can also generate State/Province for a particular country by specifying the country name you want to generate for.

USAGE
=====

[](#usage)

Install Package
---------------

[](#install-package)

```
composer require wisdom-diala/countrypkg-laravel

```

### Create database if you don't have any database yet.

[](#create-database-if-you-dont-have-any-database-yet)

### Run migration

[](#run-migration)

```
php artisan migrate

```

After running migration, it will create two tables countries and states table

### Run this command on your terminal to generate countries

[](#run-this-command-on-your-terminal-to-generate-countries)

```
php artisan g:c

```

This command will generate all countries around the world with it's country code and short name and save it in the countries table it created earlier.

### Run this command on your terminal to generate all states/province

[](#run-this-command-on-your-terminal-to-generate-all-statesprovince)

```
php artisan g:s all

```

This command generate all states with it's country ID from the country table that was initially created.

### To generate states/province for a particular country run this command

[](#to-generate-statesprovince-for-a-particular-country-run-this-command)

```
php artisan g:s Nigeria

```

This command will generate all states/province in Nigeria.

### Publish asset files

[](#publish-asset-files)

```
php artisan vendor:publish --tag=country_flags

```

This command will publish the country flags images inside public/wisdom\_countrypkg/img/country\_flags

Using it in your controller
---------------------------

[](#using-it-in-your-controller)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use WisdomDiala\Countrypkg\Models\Country;
use WisdomDiala\Countrypkg\Models\State;

class TestController extends Controller
{
    public function getAllCountries()
    {
    	$countries = Country::all();
    	return view('pages.countries', compact('countries'));
    }

    public function getAllStates()
    {
    	$states = State::all();
    	return view('pages.states', compact('states'));
    }
}
```

Note: Make sure you import the Country and State Model that was shipped with the package.

#### That's all, you now have states and countries records in your local database and can use it anytime you want.

[](#thats-all-you-now-have-states-and-countries-records-in-your-local-database-and-can-use-it-anytime-you-want)

Watch the video on how to use the package here:

Countries and states records pulled from this API

### Note: After installation of the package, you don't need any internet connection to generate the countries and states again.

[](#note-after-installation-of-the-package-you-dont-need-any-internet-connection-to-generate-the-countries-and-states-again)

### If you really find this useful please give us a star.

[](#if-you-really-find-this-useful-please-give-us-a-star)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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 ~102 days

Recently: every ~0 days

Total

8

Last Release

1149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/60fc15cbacd65eff41cef00e600aff3dfe17a3f40a2d8f34999ae6c71ee1eb09?d=identicon)[wisdom\_diala](/maintainers/wisdom_diala)

---

Top Contributors

[![wisdom-diala](https://avatars.githubusercontent.com/u/52057187?v=4)](https://github.com/wisdom-diala "wisdom-diala (16 commits)")[![Kenneth-Inkum](https://avatars.githubusercontent.com/u/54093343?v=4)](https://github.com/Kenneth-Inkum "Kenneth-Inkum (1 commits)")

### Embed Badge

![Health badge](/badges/wisdom-diala-countrypkg-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/wisdom-diala-countrypkg-laravel/health.svg)](https://phpackages.com/packages/wisdom-diala-countrypkg-laravel)
```

PHPackages © 2026

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