1. Go to this page and download the library: Download melsaka/world-countries library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Melsaka\WorldCountries\Country;
$countries = new Country();
// returns a laravel collection of all supported countries.
$allCountries = $countries->get();
// returns the data of a specifc country as an array
$egypt = $countries->get('eg');
// returns a laravel collection of egyptian states.
$egyptianStates = Country::states($egypt);
// returns the data of a specifc state in egypt as an array
$alexandria = Country::states($egypt, 'ALX');
use Melsaka\WorldCountries\State;
$states = new State($egypt);
// or
$states = new State('EG');
// returns a laravel collection of egyptian states.
$egyptianStates = $states->get();
// returns the data of a specifc state in egypt as an array
$alexandria = $states->get('ALX');
// returns a laravel collection of egyptian cities.
$egyptianCities = Country::cities($egypt);
// returns a laravel collection of egyptian cities that belongs to specifc state in egypt
$alexandriaCities = Country::cities($egypt, 'ALX');
// or
$alexandriaCities = Country::cities($egypt, $alexandria);
use Melsaka\WorldCountries\City;
$cities = new City($egypt);
// or
$cities = new City('EG');
// returns a laravel collection of egyptian cities.
$egyptianCities = $cities->get();
// returns a laravel collection of egyptian cities that belongs to specifc state in egypt
$alexandriaCities = $cities->get('ALX');