Download the PHP package pragmarx/countries without Composer

On this page you can find all versions of the php package pragmarx/countries. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package countries

Countries

Latest Stable Version Code Quality Build

Coverage PHP Downloads StyleCI

What does it gives you?

This package has all sorts of information about countries:

info items
taxes 32
geometry maps 248
topology maps 248
currencies 256
countries 266
timezones 423
borders 649
flags 1,570
states 4,526
cities 7,376
timezones times 81,153

Geology and topology maps

Amongst many other information you'll be able to plot country maps:

Requirements

Installing

Use Composer to install it:

Instantiating

Should both return

Overloading the default configuration:

#

Usage

This package is not tied to Laravel and doesn't require it to be installed (we have a bridge for this purpose), but it has Laravel Collections in its core, all methods in Collections are available, this way you can do things like filter, map, reduce, search, sort, reject, and a lot more. It, actually, uses Coollection, which is Laravel Collections with a fluent syntax, allowing us to have access to array keys (and values) as object properties.

To get all countries in the data base you just have to:

To get a json you:

Filter by keys and values:

Will find Brazil by its common name, which is a

Or alternatively you can filter like this

And, you can go deepeer

Or search by the country top level domain

To get

And use things like pluck

To get

The package uses a modified Collection which allows you to access properties and methods as objects:

Should give

Borders hydration is disabled by default, but you can have your borders hydrated easily by calling the hydrate method:

Should return

`

Hydration

To improve performance, hydration, which is enabled by default, can be disable on most country properties, and this is how you manually hydrate properties:

Those are some of the hydratable properties:

Extra where rules

Some properties are stored differently and we therefore need special rules for accessing them, these properties are

You can of course access them like other properties

Mapping

Sometimes you would like to access a property by a different name, this can be done in settings, this way

Here we bind the language 3 letter short code ISO format to lca3, which is short for language code alpha 3-letter. So now we can access the property by

Or

Some other examples from Laravel News and some other contributors

Generate a list of all countries with code, using native name and common

Should give you 267 (or so) countries like:

Generate a list of countries

returns

Generate a list of currencies

returns

Get the currency symbol

Generate a list of States

returns

Hydrate and get a cities

Should return

Get a countries currencies

returns

Get all currencies

returns

Get the timezone for a State

returns

Get all timezones for a country

Get all times for a timezone

returns

Flags

Countries provides many different flag sources, including SVG flags. This is how you use one of the available sources:

Install flag-icon

Import it to your project

Use Countries to get the flag span

Render it in your blade template

Publishing assets

You can publish configuration by doing:

Data

Sources

This package uses some other open source packages and, until we don't build a better documentation, you can find some more info about data on mledoze/countries and how to use it on this fantastic Laravel News article.

Please check the copyright section for a complete list of packages used by this one.

Updating

WARNING

No data files (JSON, images, icons...) on this project can be updated manually. We will close all pull requests requiring manual updates to those files will be closed, because the update script will delete them anyway.

If you find something wrong with data, you, please, have to ask the package managers (listed data sources and on the copyright section) to fix them, and then you can yourself run the update script to properly update them on this repository.

update.php

This package comes with the update.php script, which you MUST use to update the data files. It will download all info from all packages and automatically build the .json (and some others like .svg too). This is how you do it:

And wait for a *very long time** (sometimes it looks like stuck but it's not) until it finishes rebuilding everything, then it's just a matter of staging, commit, push all regenerated files, and draft a new PR.

Cache

Since this data is not supposed to change, calls are automatically cached. If you want to change this behaviour, you can edit config/countries.php file once it's published.

Framework bridges

Sample files

Author

Antonio Carlos Ribeiro All contributors

Copyright

To build the countries database and relations, this package make use of those sources and packages:

License

Countries is licensed under the BSD 3-Clause License - see the LICENSE file for details

Contributing

Pull requests and issues are more than welcome.


All versions of countries with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
pragmarx/coollection Version >=0.8
psr/simple-cache Version ^1.0|^2.0
nette/caching Version ^2.5|^3.0
colinodell/json5 Version ^1.0|^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pragmarx/countries contains the following files

Loading the files please wait ....