{"id":17726620,"url":"https://github.com/thedevsaddam/world-countries","last_synced_at":"2025-05-08T20:36:35.379Z","repository":{"id":57085042,"uuid":"66941154","full_name":"thedevsaddam/world-countries","owner":"thedevsaddam","description":"Provide world country list with country code, city, states and flag","archived":false,"fork":false,"pushed_at":"2016-09-15T18:38:21.000Z","size":1213,"stargazers_count":19,"open_issues_count":3,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-29T02:04:11.674Z","etag":null,"topics":["city","countries","world"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/thedevsaddam/world-countries","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thedevsaddam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-30T13:05:10.000Z","updated_at":"2024-03-29T02:04:11.675Z","dependencies_parsed_at":"2022-08-24T22:50:37.977Z","dependency_job_id":null,"html_url":"https://github.com/thedevsaddam/world-countries","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fworld-countries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fworld-countries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fworld-countries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fworld-countries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thedevsaddam","download_url":"https://codeload.github.com/thedevsaddam/world-countries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246515267,"owners_count":20790024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["city","countries","world"],"created_at":"2024-10-25T17:06:19.137Z","updated_at":"2025-04-01T07:30:59.319Z","avatar_url":"https://github.com/thedevsaddam.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"World Countries\n===================\n\n\nThis package contains world country list along with states, cities, country code and country flags.\n\n----------\n\n\nInstallation\n-------------\nVia Composer\n\n``` bash\n$ composer require thedevsaddam/world-countries\n```\nInstall manually (add the line to composer.json file)\n``` bash\n\"thedevsaddam/world-countries\": \"1.1\"\n```\nOpen your terminal and hit the command\n```bash\ncomposer update\n```\n\nAdd the following line to config/app.php file\n\n```bash\nThedevsaddam\\WorldCountries\\WorldCountriesServiceProvider::class,\n```\nTo publish the configuration and resources\n\n```bash\nphp artisan vendor:publish\n```\n\n###### ***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***\n```bash\nphp artisan world-countries:populate\n```\nThe above command will populate the countries and other tables to database\n\nTo drop the populated tables\n```bash\nphp artisan world-countries:drop\n```\n\n### **Features**\n1. World country list with Official name, short name, flag, latitude, longitude.\n1. World country list with states and cities\n1. World Timezones (coming soon)\n\n### **Usage**\nTo fetch all the countries with flag. This will return a collection object so that you can use the available method of Collection class\n\n```php\nWorldCountries::getCountriesWithFlag();\n```\n\n\n##### Example\n```php\n$countries = WorldCountries::getCountriesWithFlag();\nforeach($countries as $key =\u003e $country){\n    echo \"\u003cimg src='\".$country['flagLargeUrl'].\"' /\u003e\";\n    echo $country['name'];\n    echo \"\u003cbr/\u003e\u003chr/\u003e\";\n}\n// you can use all the method of Collection class\n\n$country = WorldCountries::getCountriesWithFlag()-\u003ewhere('name', 'Bangladesh');\n```\n\n#### Fetch all the countries with  state and cities ####\n```php\n$countries = WorldCountries::getCountriesWithStateCity();\n\n//Note: This query will take some time to fetch all the countries with its associate states and cities\n\n```\n#### Get Eloquent model to perform custom query\n\n```php\n$countryModel = WorldCountries::getCountryModel();\n\n//Fetch all the countries in array\n$countries = $countryModel-\u003eget()-\u003etoArray();\n\n//Fetch all the countries with states\n$countriesWithStates = $countryModel-\u003ewith('states')-\u003eget();\n\n//Note: you can use Laravel eloquent available methods (See the below example)\n\n$countryModel = WorldCountries::getCountryModel();\n$country = $countryModel-\u003ewhere('name', 'Bangladesh')-\u003efirst();\n```\n\nNote: You can get city and state model as well.  To get them use the methods below\n```php\n$stateModel = WorldCountries::getStateModel();\n$cityModel = WorldCountries::getCityModel();\n//now you can perform any query available to Eloquent model\n```\n\n###### Best uses of this package is to populate dropdown with countries.\n```php\n//first get all the countries and populate the country dropdown\n$countryModel = WorldCountries::getCountryModel();\n$countries = $countryModel-\u003elists('name', 'id');\n\n//you can make an endpoint to fetch all the states against some individual country\n$stateModel = WorldCountries::getStateModel();\n$states = $stateModel-\u003ewhere('country_id', $someRequest-\u003ecountryId)-\u003eget()-\u003etoArray();\nreturn response()-json($states);\n\n// now make another endpoint against the state and fetch all of it's cities.\n$cityModel = WorldCountries::getCityModel();\n$cities = $cityModel-\u003ewhere('state_id', $someRequest-\u003estateId)-\u003eget()-\u003etoArray();\nreturn response()-\u003ejson($cities);\n```\n\n##### Config\nIf you change the flag directory name or path then update the config/flag.php file_path according to the path name\n\n##### Credit\n\n###### Flag and country list json from: [cristiroma](https://github.com/cristiroma/countries)\n\n###### Countries, state and cities mysql dump from: [cristiroma](https://github.com/cristiroma/countries)\n\nThank you :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedevsaddam%2Fworld-countries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedevsaddam%2Fworld-countries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedevsaddam%2Fworld-countries/lists"}