The Country Codes package is a Composer plugin that provides an automated version of the Country Codes database. This database includes country, iso-codes, country names, country names with phone codes, phone codes as well an admin page to manage your list of data.
What this package can do?
- Get users country names
- Get users phone numbers
- Send OTP codes
- Send messages on messengers
Usage of this package varies, those were just small examples of what you can do.
Also, my main reason to build this package was to send WhatsApp messages (specifically OTP codes).
Installation
The only thing you need to do to make this work is to add this package as a dependency to your project:
composer require irando/country-codes
Usage
Add following line in your config/app.php file
'providers' => [
// ...
Irando\CountryCodes\CountryCodesServiceProvider::class,
];
Run either of the commands below to publish package files
php artisan vendor:publish
And select id referred to:
Irando\CountryCodes\CountryCodesServiceProvider
OR
php artisan vendor:publish --tag=country-codes
Run this command to add countries table into your database
php artisan migrate
Next, Run this command to seed countries data into countries table.
php artisan db:seed --class=CountryCodesTableSeeder
Note: In case of error after this command run composer dumpautoload and try again to seed database
Now visit your_url.tld/country-codes and you are set.
Customization
If you need (probably you do!) to customize the look, routing, functionality, etc. of this package, at stage 2 of installation we deployed CountryCodes.php which is your table model, as well as view files at resources/views/vendor/irando/country-codes you can edit those files and create your own.
For more details, Please visit Github