• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🌎 Geodata API - Get countries, and cities to plug in drop-downs.

Country City API

Build Status Code Climate codecov License

Geodata API to get the list of countries and cities in the world. This can be plugged in country and city picker drop-downs in forms. You can find a select2 implementation here. Code for this implementation is in example directory.

⚑ Installing the CountryCity API

  • Make sure you have PHP 7.4 or newer.
$ php -v
  • Download this API using composer using the command below.
composer global require shivammathur/countrycity "dev-main"
  • Then install the API by executing the command below.
composer create-project shivammathur/countrycity countrycity "dev-main" --prefer-dist
  • You are all set, you can use this API.

#️⃣ API Endpoints

All API responses are in json format.

  • Get all countries
/countries

# Without URL Rewriting
/index.php/countries
  • Get all countries containing a search keyword
/countries/{search_keyword}

# Without URL Rewriting
/index.php/countries/{search_keyword}
  • Get all cities in a country
/cities/{country}

# Without URL Rewriting
/index.php/cities/{country}
  • Get all cities in a country containing a search keyword
/cities/{country}/{search_keyword}

# Without URL Rewriting
/index.php/cities/{country}/{search_keyword}

✨ Rest API Features

  • Built using Slim micro framework.
  • Caching enabled with following headers
    • ETag
    • Expires
    • Last-Modified
  • Fast and lightweight API
  • PSR 7 Complaint
  • CORS Middleware

☁️ Hosting configuration

Here are the Configuration Instructions if you want to host this on your server.

πŸ”§ Error Format

If there is an error in the API, you will get an error in json format as response

{"error":"true", "message": "error message here"}

🚨 Testing

$ vendor/bin/phpunit --configuration phpunit.xml.dist

πŸ“œ License

The scripts and documentation in this project are released under the MIT License. This project has multiple dependencies and their licenses can be found in their respective repositories.

πŸ‘ Contributions

Contributions are welcome! See Contributor's Guide.

πŸ’– Support this project

  • Please star the project and share it with the community.
  • Support the project by sponsoring my work on GitHub sponsors.

More Repositories

1

setup-php

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
TypeScript
2,863
star
2

homebrew-php

🍺 Homebrew tap for PHP 5.6 to 8.4. PHP 8.4 is built nightly.
Ruby
2,443
star
3

homebrew-extensions

🍻 Homebrew tap for PHP extensions
Ruby
630
star
4

php-builder

🐘 Build PHP 5.6 and newer
Shell
65
star
5

IPpy

πŸš€ Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.
Python
57
star
6

cache-extensions

πŸ“¦ Cache PHP extensions in GitHub Actions
Shell
47
star
7

php-builder-windows

Build PHP 8.0 and above nightly snaps for Windows.
PowerShell
46
star
8

php5-ubuntu

Scripts to install the end-of-life PHP versions on Ubuntu 22.04, 20.04 and 18.04 amd64
Shell
25
star
9

TwitterScraper

Twitter Scraper - Scrape tweets for a user or a #hashtag.
Python
13
star
10

node-docker

Docker images with Node.js and PHP for CI
Shell
10
star
11

php-src-backports

Security backports for EOL versions of PHP.
Roff
9
star
12

icu-intl

Compiled versions of icu4c and intl php extension
Shell
7
star
13

php-extensions-windows

Build PHP extensions for windows
PowerShell
7
star
14

ghsvg

GitHub Sponsors SVG
TypeScript
7
star
15

codementor-mentees

Shivam Mathur's Codementor Mentees
JavaScript
6
star
16

php-ubuntu

Cached packages to install PHP on Ubuntu in GitHub Actions
Shell
6
star
17

composer-cache

Cache composer phars for setup-php.
Shell
6
star
18

test-setup-php

Testing Setup PHP GitHub Action
6
star
19

spc

setup-php-cli (spc) is a command line utility to run setup-php.
Shell
3
star
20

php5-darwin

Install PHP 5 versions on darwin
Shell
3
star
21

flask-chat-app

Chat app using flask and SocketIO in python.
JavaScript
3
star
22

php-darwin

Shell
3
star
23

shivammathur

2
star
24

.github

Default config for my GitHub projects.
2
star
25

init.lua

My nvim config
Lua
1
star
26

pacman

Classic pacman game built in python using pygame
Python
1
star
27

homebrew-openssl-deprecated

Formula for [email protected]
Ruby
1
star
28

homebrew-phalcon

Please use shivammathur/extensions tap instead.
Ruby
1
star
29

Computer-Networks-OMNeT-Lab

Assignments of my computer networks lab
C++
1
star