Giter Club home page Giter Club logo

countries's Introduction

Countries

World Map

Latest Stable Version License 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:

Switzerland

Requirements

  • PHP 7.0+

Installing

Use Composer to install it:

composer require pragmarx/countries

Instantiating

use PragmaRX\Countries\Package\Countries;

$countries = new Countries();

echo $countries->where('cca2', 'IT')->first()->hydrateCurrencies()->currencies->EUR->coins->frequent->first();

// or calling it statically

echo Countries::where('cca2', 'IT')->first()->hydrateCurrencies()->currencies->EUR->coins->frequent->first();

Should both return

€1

Overloading the default configuration:

use PragmaRX\Countries\Package\Services\Config;

$countries = new Countries(new Config([
    'hydrate' => [
        'elements' => [
            'currencies' => true,
            'flag' => true,
            'timezones' => true,
        ],
    ],
]));

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:

use PragmaRX\Countries\Package\Countries;

$countries = new Countries();

$all = $countries->all();

To get a json you:

return $countries->toJson();

Filter by keys and values:

$countries->where('name.common', 'Brazil');

Will find Brazil by its common name, which is a

#items: array:22 [▼
  "name" => array:3 [▼
    "common" => "Brazil"
    "official" => "Federative Republic of Brazil"
    "native" => array:1 [▼
      "por" => array:2 [▼
        "official" => "República Federativa do Brasil"
        "common" => "Brasil"
      ]
    ]
  ]

Or alternatively you can filter like this

$countries->whereNameCommon('Brazil');

And, you can go deepeer

$countries->where('name.native.por.common', 'Brasil');

Or search by the country top level domain

$countries->where('tld.0', '.ch');

To get

"name" => array:3 [▼
  "common" => "Switzerland"
  "official" => "Swiss Confederation"
  "native" => array:4 [▶]
]
"tld" => array:1 [▼
  0 => ".ch"
]

And use things like pluck

$countries->where('cca3', 'USA')->first()->hydrateStates()->states->pluck('name', 'postal')->toArray();

To get

"MA" => "Massachusetts"
"MN" => "Minnesota"
"MT" => "Montana"
"ND" => "North Dakota"
...

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

$countries->where('cca3', 'FRA')
         ->first()
         ->borders
         ->first()
         ->name
         ->official;

Should give

Principality of Andorra

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

$countries->where('name.common', 'United Kingdom')
         ->hydrate('borders')
         ->first()
         ->borders
         ->reverse()
         ->first()
         ->name
         ->common;

Should return

Ireland

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:

$countries->where('name.common', 'United States')->first()->hydrate('timezones')->timezones->first()->zone_name;

$countries->where('name.common', 'United States')->first()->hydrate('timezones')->timezones->first()->zone_name;

Those are some of the hydratable properties:

  • Borders
  • Cities
  • Currencies
  • Flag
  • Geometry
  • Languages
  • States
  • Taxes
  • Timezone
  • Topology

Extra where rules

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

  • ISO639_3 => The 3 letter language code.
  • ISO4217 => The 3 letter currency code.

You can of course access them like other properties

$countries->whereISO639_3('por')->count();
$countries->where('ISO639_3', 'por')->count();

Mapping

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

'maps' => [
    'lca3' => 'ISO639_3'
]

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

$countries->whereLca3('por');

Or

$countries->where('lca3', 'por');

Some other examples from Laravel News and some other contributors

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

app(PragmaRX\Countries\Package\Countries::class)
->all()
->map(function ($country) {
    $commonName = $country->name->common;

    $languages = $country->languages ?? collect();

    $language = $languages->keys()->first() ?? null;

    $nativeNames = $country->name->native ?? null;

    if (
        filled($language) &&
            filled($nativeNames) &&
            filled($nativeNames[$language]) ?? null
    ) {
        $native = $nativeNames[$language]['common'] ?? null;
    }

    if (blank($native ?? null) && filled($nativeNames)) {
        $native = $nativeNames->first()['common'] ?? null;
    }

    $native = $native ?? $commonName;

    if ($native !== $commonName && filled($native)) {
        $native = "$native ($commonName)";
    }

    return [$country->cca2 => $native];
})
->values()
->toArray();

Should give you 267 (or so) countries like:

"AW" => "Aruba"
"AF" => "افغانستان (Afghanistan)"
"AO" => "Angola"
"AI" => "Anguilla"
"AX" => "Åland (Åland Islands)"
"AL" => "Shqipëria (Albania)"
"AD" => "Andorra"
"AE" => "دولة الإمارات العربية المتحدة (United Arab Emirates)"
"AR" => "Argentina"
"AM" => "Հայաստան (Armenia)"
"AS" => "American Samoa"
"AQ" => "Antarctica"
"TF" => "Terres australes et antarctiques françaises (French Southern and Antarctic Lands)"
"AG" => "Antigua and Barbuda"
"AU" => "Australia"
"AT" => "Österreich (Austria)"
"AZ" => "Azərbaycan (Azerbaijan)"
"BI" => "Burundi"
"BE" => "Belgien (Belgium)"
"BJ" => "Bénin (Benin)"
"BF" => "Burkina Faso"
"BD" => "বাংলাদেশ (Bangladesh)"
"BG" => "България (Bulgaria)"
"BH" => "‏البحرين (Bahrain)"
"BS" => "Bahamas"
"BA" => "Bosna i Hercegovina (Bosnia and Herzegovina)"
"BL" => "Saint-Barthélemy (Saint Barthélemy)"
"SH" => "Saint Helena, Ascension and Tristan da Cunha"
"BY" => "Белару́сь (Belarus)"
"BZ" => "Belize"
"BM" => "Bermuda"
"BO" => "Wuliwya (Bolivia)"
"BQ" => "Caribisch Nederland (Caribbean Netherlands)"
"BR" => "Brasil (Brazil)"
"BB" => "Barbados"
"BN" => "Negara Brunei Darussalam (Brunei)"
"BT" => "འབྲུག་ཡུལ་ (Bhutan)"
"BV" => "Bouvetøya (Bouvet Island)"
"BW" => "Botswana"
"CF" => "République centrafricaine (Central African Republic)"
"CA" => "Canada"
"CC" => "Cocos (Keeling) Islands"
"CH" => "Suisse (Switzerland)"
"CL" => "Chile"
"CN" => "** (China)"
"CI" => "Côte d'Ivoire (Ivory Coast)"
"CM" => "Cameroon"
"CD" => "RD Congo (DR Congo)"
"CG" => "République du Congo (Republic of the Congo)"
"CK" => "Cook Islands"
"CO" => "Colombia"
"KM" => "القمر‎ (Comoros)"
"CV" => "Cabo Verde (Cape Verde)"
...

Generate a list of countries

$countries->all()->pluck('name.common')->toArray();

returns

[
    "Aruba",
    "Afghanistan",
    "Angola",
    "Anguilla",
    "Åland Islands",
    ....

Generate a list of currencies

$countries->all()->pluck('currencies')->toArray();

returns

[
  [
    "AWG",
  ],
  [
    "AFN",
  ],
  [
    "AOA",
  ],
  [
    "XCD",
  ],
  [
    "EUR",
  ],
  ....

Get the currency symbol

$countries->where('name.common', 'Brazil')->first()->hydrate('currencies')->currencies->BRL->units->major->symbol;

Generate a list of States

$countries->where('name.common', 'United States')
    ->first()
    ->hydrateStates()
    ->states
    ->sortBy('name')
    ->pluck('name', 'postal');

returns

[
    "AL": "Alabama",
    "AK": "Alaska",
    "AZ": "Arizona",
    "AR": "Arkansas",
    "CA": "California",
    ....
    ....

Hydrate and get a cities

$countries->where('cca3', 'FRA')
    ->first()
    ->hydrate('cities')
    ->cities
    ->paris
    ->timezone;

Should return

Europe/Paris

Get a countries currencies

$countries->where('name.common', 'United States')->first()->currencies;

returns

[{
    "alternativeSigns": [],
    "ISO4217Code": "USD",
    "ISO4217Number": "840",
    "sign": "$",
    "subunits": 100,
    "title": "U.S. dollar",
    ....

Get all currencies

$countries->currencies();

returns

[
    0 => "AED"
    1 => "AFN"
    2 => "ALL"
    3 => "AMD"
    4 => "ANG"
    5 => "AOA"
    6 => "ARS"
    7 => "AUD"
    8 => "AWG"
    9 => "AZN"
    10 => "BAM"
    ....

Get the timezone for a State

return $countries->where('name.common', 'United States')->first()->timezone->NC;

returns

America/New_York

Get all timezones for a country

$countries->where('name.common', 'Brazil')
  ->first()
  ->hydrateTimezones()
  ->timezones
  ->map(function ($timezone) {
      return $timezone->zone_name;
  })->values()
  ->unique()
  ->toArray();

Get all times for a timezone

return $countries->where('name.common', 'United States Virgin Islands')->first()->hydrate('timezones_times')->timezones->first()->times;

returns

"times" => [
    "abbreviation" => "LMT"
    "dst" => "0"
    "gmt_offset" => "-14764"
    "time_start" => "-1825098837"
    "zone_id" => "415"
    1 => [
        "abbreviation" => "AST"
        "dst" => "0"
        "gmt_offset" => "-14400"
        "time_start" => "-1825098836"
        "zone_id" => "415"
    ]
]

Flags

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

Install flag-icon

npm install --save-dev flag-icon-css

Import it to your project

@import '~flag-icon-css/sass/flag-icon.scss';

Use Countries to get the flag span

$unitedStatesFlag =
    $this->countries->where('cca3', 'USA')
    ->first()
    ->flag
    ->flag_icon;

Render it in your blade template

{!! $unitedStatesFlag !!}

Publishing assets

You can publish configuration by doing:

php artisan vendor:publish --provider=PragmaRX\\Countries\\ServiceProvider

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:

cd vendor/pragmarx/countries
composer install
php update.php

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.

countries's People

Contributors

0ly avatar amenk avatar amirasyraf avatar antonioribeiro avatar artem-schander avatar b00f avatar christhompsontldr avatar coding-sunshine avatar evrard-c avatar grrnikos avatar iasjennen avatar kkszymanowski avatar marclaporte avatar olimortimer avatar olivernybroe avatar omranic avatar ralbear avatar reinierkors avatar stylecibot avatar vortechron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

countries's Issues

Adding States

Hello @antonioribeiro ,

Thanks for this awesome effort you have put to create this package. Kudos! I am trying to use this library in one of my projects and I have found that some data is currently missing.

I want to help myself out and in process also help you and the entire community at large by filling in the blanks where ever possible.

I have here a list of countries without states:

ALA Åland Islands

ATG Antigua and Barbuda

BEL Belgium

BIH Bosnia and Herzegovina

ESH Western Sahara

IRQ Iraq

UNK Kosovo

NOR Norway

PNG Papua New Guinea

PRT Portugal

PSE Palestine

SJM Svalbard and Jan Mayen

SOM Somalia

SRB Serbia

SSD South Sudan

SYR Syria

UMI United States Minor Outlying Islands

I have a database with me that has the list of states for the above countries. Could you please guide me as to what convention have you used to generate the state json data? What is the purpose of each field and how I can fill them out with proper and correct data?

Looking forward for your response. Thanks a lot.

Regards,
Ajitem

Windows Reserved File Name

Cannot checkout this repo on Windows because this file uses a reserved word: src/data/states/nul.json

Here is the full status log when trying "composer install" on Vagrant box with Windows host:

  - Installing pragmarx/countries (v0.1.0): Downloading (connecting...)���������������������������Downloading (100%)         ���������
    Failed to download pragmarx/countries from dist: Could not delete /vagrant/platform/vendor/pragmarx/countries/493f0c91fc8d34dc6039ba82c91f51e3: 
    Now trying to download from source
  - Installing pragmarx/countries (v0.1.0): Cloning f190ff8132
    f190ff8132208dd22655ccb3bb5f9a2e31a3872e is gone (history was rewritten?)

                                                                                                                                                  
  [RuntimeException]                                                                                                                              
  Failed to execute git checkout 'f190ff8132208dd22655ccb3bb5f9a2e31a3872e' -- && git reset --hard 'f190ff8132208dd22655ccb3bb5f9a2e31a3872e' --  
  HEAD is now at f190ff8... Reorder items                                                                                                         
  error: git checkout-index: unable to create file src/data/states/nul.json (Protocol error)                                                      
  fatal: Could not reset index file to revision 'f190ff8132208dd22655ccb3bb5f9a2e31a3872e'.

how to implement this in my app?

Hi,
I just installed this package on my app but have no idea how to make it work.

  1. I used
    php artisan vendor:publish --provider=PragmaRX\\Countries\\ServiceProvider
    nothing added to my config folder.

  2. i don't know i must expect any table in my database for these country and states list or not? cause there is nothing added in my migration folder as well.

3- have no idea what should i use in my controller to order to get that lists.

Would be appreciate if someone explain a bit about this package and how it works.

Thanks

Blade using

Hi,

Please someone help me with using this in my application, currently i'm not confused anymore but desperate!

here is my controller:

use PragmaRX\Countries\Facade as Countries;
//.....
public function create()
    {
        $users = User::all();
        $countries = Countries::all()->pluck('name.common');
        return view('admin.addresses.create', compact('users', 'countries'));
    }
//......

and this is my blade code:

{{Form::label('country', 'Country')}}
<select class="form-control" name="country">
  @foreach($countries as $country)
     <option value="">{{$country}}</option>
  @endforeach
</select>

What I want to achieve is:

  1. List of countries (which i have)

  2. List of states based on selected country

  3. List of postal codes based on selected states

Ps: if it's possible to get countries flags very well if not, it's not important thing for me.

Thanks in advance. Hope someone can help :\

Calling Code Validation

The country code must be a valid callingCode. This is the validation error generated when I am trying to Implement Calling Code Validation in my app. Country Validation works perfectly fine but Calling Code does not. Below is my Implementation:

File: config\countries.php

<?php

return [

    'cache' => [
        'enabled' => true,

        'service' => PragmaRX\Countries\Support\Cache::class,

        'duration' => 180,
    ],

    'hydrate' => [
        'before' => true,

        'after' => true,

        'elements' => [
            'flag' => true,
            'currency' => true,
            'states' => true,
            'timezone' => true,
            'borders' => false,
            'topology' => true,
            'geometry' => true,
            'collection' => true,
        ],
    ],
    'maps' => [
        'lca3' => 'ISO639_3',
        'currency' => 'ISO4217',
    ],

    'validation' => [
        'enabled'    => true,
        'rules'    => [
            'country'            => 'name.common',
            'cca2',
            'cca2',
            'cca3',
            'ccn3',
            'cioc',
            'currency'            => 'ISO4217',
            'language',
            'language_short'    => 'ISO639_3',
            'callingCode',
        ],

File: `app\Http\Controllers...Controller.php

public function validate(array $data) {
        return Validator::make($data, [
            'country' => 'required|alpha|country',
            'country_code' => 'required|callingCode:'.$data['country'],
            'phone' => 'required|numeric|unique:users',
        ]);
}

Note: country field is being successfully validated but country_code is not.

Return empty when I make a mistake to send invalid code

Hi,
I have a problem, when send an invalid code, the collection not return empty.
Example

$c = Countries::where('cca2', 'EX')->first()->states->where('name','<>','')->pluck('name','adm1_cod_1')->toArray();

I force to send EX

This is return

FatalThrowableError in Collection.php line 84:
Access to undeclared static property: PragmaRX\Countries\Support\Collection::$proxies

How return a simple empty or how catch error?

Publishing Assets/Config

Not sure but when running the publish command in the Readme, shows as publishing complete but nothing is published, even without specifying a tag nothing is published?

List of country states

I will get all of country state using this code
$countries = Countries::all();
I loop all of the countries and I've used contains to determine that $country have no states.

if ($country->contains('states')) {
            echo(' have state');
 } else {
            echo('  no state');
}

So here I found out Antigua and Barbuda have no state it that if condition cathes it but on the
"Republic of Kosovo" , "Republic of Serbia", "Republic of South Sudan" it throws error. because it passes the if else condition even that countries have no state. I dump the results but it is the same to "Antigua and Barbuda" states => null.
Here is my code:
AG XK RS SS - these countries have no states that throwing error except AG

$states = Countries::where('cca2', 'SS')->first();

        echo '<br>';
        echo $states->cca2 . ' ' . $states->name->official;
        if ($states->contains('states')) {
            echo(' have state');
        } else {
            echo(' no state');
        }
        dd($states);

can't publish the config file and displays a "Class 'Countries' not found" when trying to use it

I installed this interesting package and after completed Service provider and Alias i tried to use it on a form in a select input but unfortunately for me i receive an error "Class 'Countries' not found", so i tried to publish the config file, everything seemed to be right but i didn't found the countries.php in the config directory.
I don't really know if this issue comes from me or if there is some issues in the package

Get the flags as .svg-File

Hey,

thanks for the nice package! One issue I have is the following:

I want to show the flags of the countries for a language switcher. Currently I'm including them via the following code (Laravel + Bulma) into my site:

<span class="icon"><object>{!! Countries::where('name.common', 'France')->first()->hydrate('flag')->flag->svg !!}</object></span>

The problem is that this solution is not scaleable to the small icon size, it uses the default sizes from the svg. Is it possible to get the SVGs as file? e.g.:

<span class="icon"><img src="{{ Countries::where('name.common', 'France')->first()->hydrate('flag')->flag->svgFile() }}"></span>

With this code the svg would scale automatically to the size of the .icon-Class.

Thanks!

Timezones structure changes

Hello

I have just changed over from v0.1.1 to v0.5.6 as I am in the process of doing an upgrade to Laravel 5.6.

We use this package to get timezones for countries for input into Carbon but with the upgrade my code is no longer able to access the timezones.

So it seems you need to update your docs as for a start i didn't even get the timezones array till i did a hydrate on the timezone even though i had set it to true in the config. Then i have found that you have changed the structure with each entry no longer by the 2 character code for the state but some long string.

So could you please clarify how we are meant to access timezones correctly now as your current changes have made it more difficult to use.

Cannot install on Laravel 5.6

Hi
Got an error while trying to update a L5.5 project:

pragmarx/countries v0.5.4 requires pragmarx/coollection ~0.5 -> satisfiable by pragmarx/coollection[v0.5.0].
    - Conclusion: remove symfony/http-kernel v4.0.4
    - Conclusion: don't install symfony/http-kernel v4.0.4

I think the problem lies in the ia-collection package that requires "symfony/var-dumper": "~3.3"

Cheers

*Feature* Localization The Countries [Feature]

Hello,
Thank You, Mr @antonioribeiro For This Cool Package 📦

It Would Be Cool If The Is A Localization Feature So Any One Could Use Its Own Languages
For Example I May Want To The Countries Name To Be In Arabic
Brazil Become برازيل In Arabic

I Believe This Would Be Helpful Of Course We Are Ready To Contribute

Quick question

Awesome package! Really appreciate it.

One quick question. When I've linked a country code (for example us or gb)
to a users table.

How would I eager load the country?

Thanks a lot!

Fallback for Countries without a anme

We use this:

            $fullList = Countries::all()->sortBy('translations.deu.common', SORT_LOCALE_STRING)->pluck('translations.deu.common', 'cca2');

And get empty countries names... Is there an easy way to fall back to english here?

screenshot_auswahl_042

Package doesn't work when using composer in production

In the src/Support/helpers.php file for function getPackageSrcDir you check whether a composer.json exists to determine the root directory of a vendor package.

In production mode in composer you don't have a composer.json for your vendors.

Very incomplete data

Would love to use this package to replace my current setup with Models and database tables, but a lot of calls for states based on country (for example for Belgium) return errors like 'Property [states] does not exist on this collection instance'., ... The ones who do return a result are often incomplete .. when I take for example the Netherlands not all postal fields are filled, so following your example:

Countries::where('name.common', 'Netherlands')
    ->first()
    ->states
    ->sortBy('name')
    ->pluck('name', 'postal');

returns only half of the provinces (and one with a blank postal field) because the postal field is empty for a lot of provinces.

So, no offense, the idea is really great and I would use this package for certain if the results would be correct, but that's not the case, so imho this package is not ready for real world use yet ... not for my current use case where correct data is crucial anyway.

How to find countries by currencies

Hi, thanks for this great package.
I was wondering if it's possible to:

Countries::whereIn('currencies', ['AUD','USD'])->get();

So far I had no luck, even just doing I had no luck:

Countries::where('currencies', 'AUD'])->get();

Thank you for any help.

IlluminateExtracted\Support\Collection type error

After upgrading to 0.5.0, I got this error:

Type error: Argument 1 passed to Illuminate\Routing\Router::sortMiddleware() must be an instance of Illuminate\Support\Collection, instance of IlluminateExtracted\Support\Collection given, called in /home/ubuntu/leadingre_com/vendor/laravel/framework/src/Illuminate/Routing/Router.php on line 675

Using Laravel 5.5

Getting translated version of a country common name

Hi, thanks for the package, looks awesome!

I'd like to know how you'd go about for translating the country common name into another language.

Say I'd wanted to bring france (FR) and display Francia (in spanish) instead of France.

At this point, I thing about mapping the collection I get and perform something like applying __($itemName) to translate them.

Any other ideas?

What makes this package require PHP 7?

Without going through the whole package, I would like to know what PHP 7 syntax is being used in this package. Anyone care to help me find out? I would like to create compatibility with PHP 5.6.

Thanks.

Map of countires states?

I get a list of states (Serbia) in table, is there a method to get a map with states borders in country map?

No pluck possible on collections?

Using previous versions in other projects I commonly used :
$countrylist = Countries::all()->pluck('name.common')->toArray();
... in order to get a complete list of all countries for my forms.

Now using Laravel 5.5 with this latest package of pragmarx/countries () it appears above this is no longer working. The first time I tried, it gives me a list. But when simply running it again, it gives me an empty array instead. I can't get head or tails on it. Nevertheless, I checked the type of the result Countries::al() and it's a collection. So normally pluck() should do just fine?!

I have tried with using both:
use PragmaRX\Countries\Package\Countries; (which I usually used)
use PragmaRX\CountriesLaravel; (which I found in the latest changelog)

I installed the serviceprovider and tried to set cache to 'false':
artisan vendor:publish --provider="PragmaRX\CountriesLaravel\Package\ServiceProvider"

dump(Countries::all()->pluck('name.common')); // not reliably working

Collection {#326 ▼
#__items: []
#allowItems: false
}

dump(Countries::where('name.common', 'France')); // working, resulting in France

Collection {#364 ▼
#__items: array:1 [▶]
#allowItems: false
#items: []
}

$countrylist = new Countries; dump($countrylist->all()); // listing full collection of 266 items

Collection {#374 ▼
#__items: array:266 [▶]
#allowItems: false
#items: []
}

dump($countrylist->all()->pluck('name.common')); // not working neither, returning empty array in collection

Collection {#355 ▼
#__items: []
#allowItems: false
}

In the end I got my result anyway with vanilla php just as I wanted:
$test = $countrylist->all()->toArray();
$result = array_pluck($test, 'name.common');

But in any case I'm reporting it here to take a look at it. I'm still learning, so either I'm doing something wrong or... something is wrong?

How do I get a list of only the signs of the currencies?

I'm currently working on a project where I need a dropdown with all currency signs. Unfortunately, I do not manage to show that. However, I'm able to show the ISO4217Code. Is there a solution or way to show only the signs in the dropdown? Thanks in advance.

Your requirements could not be resolved to an installable set of packages.

Hi,

I am using:

  • Operating System: Ubuntu 16.04 (Laravel Homestead)
  • PHP Version: PHP 7.1 (Laravel Homestead)
  • Laravel Version: 5.4

When I try to install:

composer require pragmarx/countries

I am getting the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - pragmarx/countries v0.1.1 requires mledoze/countries ^1.8 -> satisfiable b
y mledoze/countries[1.8.0].
    - Conclusion: remove symfony/routing v3.4.3
    - Conclusion: don't install symfony/routing v3.4.3
    - symfony/yaml v2.7.0 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.1 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.10 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.11 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.12 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.13 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.14 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.15 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.16 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.17 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.18 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.19 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.2 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.20 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.21 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.22 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.23 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.24 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.25 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.26 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.27 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.28 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.29 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.3 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.30 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.31 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.32 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.33 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.34 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.35 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.36 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.37 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.38 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.39 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.4 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.40 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.5 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.6 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.7 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.8 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.7.9 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.0 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.1 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.10 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.11 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.12 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.13 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.14 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.15 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.16 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.17 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.18 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.19 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.2 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.20 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.21 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.22 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.23 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.24 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.25 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.26 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.27 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.28 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.29 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.3 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.30 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.31 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.32 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.33 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.4 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.5 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.6 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.7 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.8 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v2.8.9 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.0 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.1 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.2 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.3 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.4 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.5 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.6 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.7 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.8 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.0.9 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.0 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.1 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.10 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.2 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.3 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.4 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.5 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.6 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.7 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.8 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.1.9 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.0 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.1 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.10 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.11 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.12 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.13 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.14 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.2 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.3 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.4 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.5 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.6 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.7 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.8 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.2.9 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.0 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.1 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.10 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.11 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.12 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.13 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.14 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.15 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.2 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.3 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.4 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.5 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.6 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.7 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.8 conflicts with symfony/routing[v3.4.3].
    - symfony/yaml v3.3.9 conflicts with symfony/routing[v3.4.3].
    - Installation request for symfony/routing (locked at v3.4.3) -> satisfiable
 by symfony/routing[v3.4.3].
    - Installation request for pragmarx/countries ^0.1.1 -> satisfiable by pragm
arx/countries[v0.1.1].
    - Conclusion: don't install symfony/yaml v4.0.3|install symfony/yaml v2.7.0|
install symfony/yaml v2.7.1|install symfony/yaml v2.7.10|install symfony/yaml v2
.7.11|install symfony/yaml v2.7.12|install symfony/yaml v2.7.13|install symfony/
yaml v2.7.14|install symfony/yaml v2.7.15|install symfony/yaml v2.7.16|install s
ymfony/yaml v2.7.17|install symfony/yaml v2.7.18|install symfony/yaml v2.7.19|in
stall symfony/yaml v2.7.2|install symfony/yaml v2.7.20|install symfony/yaml v2.7
.21|install symfony/yaml v2.7.22|install symfony/yaml v2.7.23|install symfony/ya
ml v2.7.24|install symfony/yaml v2.7.25|install symfony/yaml v2.7.26|install sym
fony/yaml v2.7.27|install symfony/yaml v2.7.28|install symfony/yaml v2.7.29|inst
all symfony/yaml v2.7.3|install symfony/yaml v2.7.30|install symfony/yaml v2.7.3
1|install symfony/yaml v2.7.32|install symfony/yaml v2.7.33|install symfony/yaml
 v2.7.34|install symfony/yaml v2.7.35|install symfony/yaml v2.7.36|install symfo
ny/yaml v2.7.37|install symfony/yaml v2.7.38|install symfony/yaml v2.7.39|instal
l symfony/yaml v2.7.4|install symfony/yaml v2.7.40|install symfony/yaml v2.7.5|i
nstall symfony/yaml v2.7.6|install symfony/yaml v2.7.7|install symfony/yaml v2.7
.8|install symfony/yaml v2.7.9|install symfony/yaml v2.8.0|install symfony/yaml
v2.8.1|install symfony/yaml v2.8.10|install symfony/yaml v2.8.11|install symfony
/yaml v2.8.12|install symfony/yaml v2.8.13|install symfony/yaml v2.8.14|install
symfony/yaml v2.8.15|install symfony/yaml v2.8.16|install symfony/yaml v2.8.17|i
nstall symfony/yaml v2.8.18|install symfony/yaml v2.8.19|install symfony/yaml v2
.8.2|install symfony/yaml v2.8.20|install symfony/yaml v2.8.21|install symfony/y
aml v2.8.22|install symfony/yaml v2.8.23|install symfony/yaml v2.8.24|install sy
mfony/yaml v2.8.25|install symfony/yaml v2.8.26|install symfony/yaml v2.8.27|ins
tall symfony/yaml v2.8.28|install symfony/yaml v2.8.29|install symfony/yaml v2.8
.3|install symfony/yaml v2.8.30|install symfony/yaml v2.8.31|install symfony/yam
l v2.8.32|install symfony/yaml v2.8.33|install symfony/yaml v2.8.4|install symfo
ny/yaml v2.8.5|install symfony/yaml v2.8.6|install symfony/yaml v2.8.7|install s
ymfony/yaml v2.8.8|install symfony/yaml v2.8.9|install symfony/yaml v3.0.0|insta
ll symfony/yaml v3.0.1|install symfony/yaml v3.0.2|install symfony/yaml v3.0.3|i
nstall symfony/yaml v3.0.4|install symfony/yaml v3.0.5|install symfony/yaml v3.0
.6|install symfony/yaml v3.0.7|install symfony/yaml v3.0.8|install symfony/yaml
v3.0.9|install symfony/yaml v3.1.0|install symfony/yaml v3.1.1|install symfony/y
aml v3.1.10|install symfony/yaml v3.1.2|install symfony/yaml v3.1.3|install symf
ony/yaml v3.1.4|install symfony/yaml v3.1.5|install symfony/yaml v3.1.6|install
symfony/yaml v3.1.7|install symfony/yaml v3.1.8|install symfony/yaml v3.1.9|inst
all symfony/yaml v3.2.0|install symfony/yaml v3.2.1|install symfony/yaml v3.2.10
|install symfony/yaml v3.2.11|install symfony/yaml v3.2.12|install symfony/yaml
v3.2.13|install symfony/yaml v3.2.14|install symfony/yaml v3.2.2|install symfony
/yaml v3.2.3|install symfony/yaml v3.2.4|install symfony/yaml v3.2.5|install sym
fony/yaml v3.2.6|install symfony/yaml v3.2.7|install symfony/yaml v3.2.8|install
 symfony/yaml v3.2.9|install symfony/yaml v3.3.0|install symfony/yaml v3.3.1|ins
tall symfony/yaml v3.3.10|install symfony/yaml v3.3.11|install symfony/yaml v3.3
.12|install symfony/yaml v3.3.13|install symfony/yaml v3.3.14|install symfony/ya
ml v3.3.15|install symfony/yaml v3.3.2|install symfony/yaml v3.3.3|install symfo
ny/yaml v3.3.4|install symfony/yaml v3.3.5|install symfony/yaml v3.3.6|install s
ymfony/yaml v3.3.7|install symfony/yaml v3.3.8|install symfony/yaml v3.3.9
    - Conclusion: remove symfony/yaml v4.0.3|install symfony/yaml v2.7.0|install
 symfony/yaml v2.7.1|install symfony/yaml v2.7.10|install symfony/yaml v2.7.11|i
nstall symfony/yaml v2.7.12|install symfony/yaml v2.7.13|install symfony/yaml v2
.7.14|install symfony/yaml v2.7.15|install symfony/yaml v2.7.16|install symfony/
yaml v2.7.17|install symfony/yaml v2.7.18|install symfony/yaml v2.7.19|install s
ymfony/yaml v2.7.2|install symfony/yaml v2.7.20|install symfony/yaml v2.7.21|ins
tall symfony/yaml v2.7.22|install symfony/yaml v2.7.23|install symfony/yaml v2.7
.24|install symfony/yaml v2.7.25|install symfony/yaml v2.7.26|install symfony/ya
ml v2.7.27|install symfony/yaml v2.7.28|install symfony/yaml v2.7.29|install sym
fony/yaml v2.7.3|install symfony/yaml v2.7.30|install symfony/yaml v2.7.31|insta
ll symfony/yaml v2.7.32|install symfony/yaml v2.7.33|install symfony/yaml v2.7.3
4|install symfony/yaml v2.7.35|install symfony/yaml v2.7.36|install symfony/yaml
 v2.7.37|install symfony/yaml v2.7.38|install symfony/yaml v2.7.39|install symfo
ny/yaml v2.7.4|install symfony/yaml v2.7.40|install symfony/yaml v2.7.5|install
symfony/yaml v2.7.6|install symfony/yaml v2.7.7|install symfony/yaml v2.7.8|inst
all symfony/yaml v2.7.9|install symfony/yaml v2.8.0|install symfony/yaml v2.8.1|
install symfony/yaml v2.8.10|install symfony/yaml v2.8.11|install symfony/yaml v
2.8.12|install symfony/yaml v2.8.13|install symfony/yaml v2.8.14|install symfony
/yaml v2.8.15|install symfony/yaml v2.8.16|install symfony/yaml v2.8.17|install
symfony/yaml v2.8.18|install symfony/yaml v2.8.19|install symfony/yaml v2.8.2|in
stall symfony/yaml v2.8.20|install symfony/yaml v2.8.21|install symfony/yaml v2.
8.22|install symfony/yaml v2.8.23|install symfony/yaml v2.8.24|install symfony/y
aml v2.8.25|install symfony/yaml v2.8.26|install symfony/yaml v2.8.27|install sy
mfony/yaml v2.8.28|install symfony/yaml v2.8.29|install symfony/yaml v2.8.3|inst
all symfony/yaml v2.8.30|install symfony/yaml v2.8.31|install symfony/yaml v2.8.
32|install symfony/yaml v2.8.33|install symfony/yaml v2.8.4|install symfony/yaml
 v2.8.5|install symfony/yaml v2.8.6|install symfony/yaml v2.8.7|install symfony/
yaml v2.8.8|install symfony/yaml v2.8.9|install symfony/yaml v3.0.0|install symf
ony/yaml v3.0.1|install symfony/yaml v3.0.2|install symfony/yaml v3.0.3|install
symfony/yaml v3.0.4|install symfony/yaml v3.0.5|install symfony/yaml v3.0.6|inst
all symfony/yaml v3.0.7|install symfony/yaml v3.0.8|install symfony/yaml v3.0.9|
install symfony/yaml v3.1.0|install symfony/yaml v3.1.1|install symfony/yaml v3.
1.10|install symfony/yaml v3.1.2|install symfony/yaml v3.1.3|install symfony/yam
l v3.1.4|install symfony/yaml v3.1.5|install symfony/yaml v3.1.6|install symfony
/yaml v3.1.7|install symfony/yaml v3.1.8|install symfony/yaml v3.1.9|install sym
fony/yaml v3.2.0|install symfony/yaml v3.2.1|install symfony/yaml v3.2.10|instal
l symfony/yaml v3.2.11|install symfony/yaml v3.2.12|install symfony/yaml v3.2.13
|install symfony/yaml v3.2.14|install symfony/yaml v3.2.2|install symfony/yaml v
3.2.3|install symfony/yaml v3.2.4|install symfony/yaml v3.2.5|install symfony/ya
ml v3.2.6|install symfony/yaml v3.2.7|install symfony/yaml v3.2.8|install symfon
y/yaml v3.2.9|install symfony/yaml v3.3.0|install symfony/yaml v3.3.1|install sy
mfony/yaml v3.3.10|install symfony/yaml v3.3.11|install symfony/yaml v3.3.12|ins
tall symfony/yaml v3.3.13|install symfony/yaml v3.3.14|install symfony/yaml v3.3
.15|install symfony/yaml v3.3.2|install symfony/yaml v3.3.3|install symfony/yaml
 v3.3.4|install symfony/yaml v3.3.5|install symfony/yaml v3.3.6|install symfony/
yaml v3.3.7|install symfony/yaml v3.3.8|install symfony/yaml v3.3.9
    - mledoze/countries 1.8.0 requires symfony/yaml ^2.7|^3.0 -> satisfiable by
symfony/yaml[v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.1
5, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.2
3, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.3
1, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.
4, v2.7.40, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.
8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2
.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2
.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.4, v2.8.5, v2.8
.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0
.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.
1.5, v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.1, v3.2.10, v3.2.11, v3.2.12,
v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9
, v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.2,
v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2,
v3.4.3].
    - Can only install one of: symfony/yaml[v3.4.0, v4.0.3].
    - Can only install one of: symfony/yaml[v3.4.1, v4.0.3].
    - Can only install one of: symfony/yaml[v3.4.2, v4.0.3].
    - Can only install one of: symfony/yaml[v3.4.3, v4.0.3].
    - Installation request for symfony/yaml (locked at v4.0.3) -> satisfiable by
 symfony/yaml[v4.0.3].


Installation failed, reverting ./composer.json to its original content.

Composer require with dependecy error

I'm trying to install this package with composer require pragmarx/countries.

I'm getting several dependency errors:

staging ● ?  $ composer require pragmarx/countries
 
Using version ^0.5.6 for pragmarx/countries
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Conclusion: don't install pragmarx/coollection v0.5.1
    - Installation request for pragmarx/countries ^0.5.6 -> satisfiable by pragmarx/countries[v0.5.6].
    - Conclusion: don't install symfony/var-dumper v3.0.9|install pragmarx/coollection v0.5.1
    - Conclusion: remove symfony/var-dumper v3.0.9|install pragmarx/coollection v0.5.1
    - pragmarx/countries v0.5.6 requires pragmarx/coollection ~0.5 -> satisfiable by pragmarx/coollection[v0.5.0, v0.5.1, v0.5.2, v0.5.3, v0.5.4, v0.5.5, v0.5.6, v0.5.7].
    - pragmarx/coollection v0.5.0 requires pragmarx/ia-collection >=5.5.33 -> satisfiable by pragmarx/ia-collection[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/coollection v0.5.2 requires pragmarx/ia-arr >=5.5.33 -> satisfiable by pragmarx/ia-arr[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/coollection v0.5.3 requires pragmarx/ia-arr >=5.5.33 -> satisfiable by pragmarx/ia-arr[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/coollection v0.5.4 requires pragmarx/ia-arr >=5.5.33 -> satisfiable by pragmarx/ia-arr[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/coollection v0.5.5 requires pragmarx/ia-arr >=5.5.33 -> satisfiable by pragmarx/ia-arr[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/coollection v0.5.6 requires pragmarx/ia-arr >=5.5.33 -> satisfiable by pragmarx/ia-arr[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/coollection v0.5.7 requires pragmarx/ia-arr >=5.5.33 -> satisfiable by pragmarx/ia-arr[v5.5.33, v5.6.0, v5.6.1, v5.6.2, v5.6.3].
    - pragmarx/ia-collection v5.5.33 requires symfony/var-dumper ~3.3 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].
    - pragmarx/ia-collection v5.6.0 requires symfony/var-dumper ~3.3|~4.0 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4, v4.0.0, v4.0.1, v4.0.2, v4.0.3, v4.0.4].
    - pragmarx/ia-collection v5.6.1 requires symfony/var-dumper ~3.3|~4.0 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4, v4.0.0, v4.0.1, v4.0.2, v4.0.3, v4.0.4].
    - pragmarx/ia-collection v5.6.2 requires symfony/var-dumper ~3.3|~4.0 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4, v4.0.0, v4.0.1, v4.0.2, v4.0.3, v4.0.4].
    - pragmarx/ia-collection v5.6.3 requires symfony/var-dumper ~3.3|~4.0 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4, v4.0.0, v4.0.1, v4.0.2, v4.0.3, v4.0.4].
    - pragmarx/ia-arr v5.5.33 requires symfony/var-dumper ~3.3 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].
    - pragmarx/ia-arr v5.6.0 requires symfony/var-dumper ~3.3 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].
    - pragmarx/ia-arr v5.6.1 requires symfony/var-dumper ~3.3 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].
    - pragmarx/ia-arr v5.6.2 requires symfony/var-dumper ~3.3 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].
    - pragmarx/ia-arr v5.6.3 requires symfony/var-dumper ~3.3|~4.0 -> satisfiable by symfony/var-dumper[v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4, v4.0.0, v4.0.1, v4.0.2, v4.0.3, v4.0.4].
    - Can only install one of: symfony/var-dumper[v3.3.0, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.1, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.10, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.11, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.12, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.13, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.14, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.15, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.16, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.2, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.3, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.4, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.5, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.6, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.7, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.8, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.3.9, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.4.0, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.4.1, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.4.2, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.4.3, v3.0.9].
    - Can only install one of: symfony/var-dumper[v3.4.4, v3.0.9].
    - Can only install one of: symfony/var-dumper[v4.0.0, v3.0.9].
    - Can only install one of: symfony/var-dumper[v4.0.1, v3.0.9].
    - Can only install one of: symfony/var-dumper[v4.0.2, v3.0.9].
    - Can only install one of: symfony/var-dumper[v4.0.3, v3.0.9].
    - Can only install one of: symfony/var-dumper[v4.0.4, v3.0.9].
    - Installation request for symfony/var-dumper (locked at v3.0.9) -> satisfiable by symfony/var-dumper[v3.0.9].
Installation failed, reverting ./composer.json to its original content.

My composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "repositories":[
        {
            "url":"https://github.com/eduardostuart/api.git",
            "type":"git",
            "reference":"f7e09cb070d0889a8ad9e08aaa02ff474a0ecb96"
        },
        {
            "url":"https://github.com/gabfr/PushNotification.git",
            "type":"git"
        },
        {
            "url":"https://github.com/gabfr/Search-Replace-DB.git",
            "type":"git"
        },
        {
            "url":"https://github.com/gabfr/shorty.git",
            "type":"git"
        }
    ],
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "dingo/api": "dev-master",
        "tymon/jwt-auth": "^0.5.9",
        "cviebrock/eloquent-sluggable": "^3.1",
        "barryvdh/laravel-cors": "^0.8.0",
        "laravel/socialite": "^2.0",
        "doctrine/dbal": "^2.5",
        "minishlink/web-push": "^1.4",
        "pda/pheanstalk": "^3.1",
        "mikemclin/laravel-wp-password": "~2.0.0",
        "edujugon/push-notification": "^2.1",
        "interconnectit/search-replace-db": "dev-master",
        "felixkiss/uniquewith-validator": "^3.1",
        "jamesryanbell/cloudflare": "^1.11",
        "zizaco/entrust": "5.2.x-dev",
        "mbarwick83/shorty": "dev-master",
        "google/apiclient": "^2.0",
        "dimsav/laravel-translatable": "6.1",
        "webpatser/laravel-countries": "dev-master"
    },
    "require-dev":{
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php",
            "tests/TestCaseProductionIntegration.php"
        ],
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Improve documentation

The main README is including outdated informations, telling that this library is based on Laravel.
Such parts should be moved to the Laravel bridge and framework-agnostic instructions should be provided

Unable to publish configuration file

According to documentation, then it should be possible to publish the packages config file using

php artisan vendor:publish --provider=PragmaRX\Countries\ServiceProvider

But no configuration file is generated.

Clearing the cache with php artisan config:clear does not seem to fix the issue nor does php artisan cache:clear

I am currently testing on Laravel 5.5.

Problem on the laravel 5.5

Sometimes when i do this request Countries::all()->pluck('translations.rus.common', 'postal') in my controller i see sometimes slow download page and sometimes see error about wait more 60 seconds. Help me. please

Flag Icon - 3166-1-alpha-2 not cca3

I've started to use the flag-icon and noticed this is using cca3, however lipis/flag-icon-css, which I assume is what this is intended for use with, uses 3166-1-alpha-2 for the country code, not cca3.

For using the flags inline with text add the classes .flag-icon and .flag-icon-xx (where xx is the ISO 3166-1-alpha-2 code of a country) to an empty . If you want to have a squared version flag then add the class flag-icon-squared as well.

https://github.com/lipis/flag-icon-css#usage

Error found on Laravel 5.5

Hi, is there any fix for this error? I really need this library for my Laravel application. 👍

I've successfully installed the library in ubuntu 16.0 php 7.0 and laravel 5.5 and tested Country:all() and it returns this error Trait 'Tightenco\Collect\Support\Traits\Macroable' not found

Phone number

Hi
Can you include Phone format in E164 as feature ?

Service Provider

Hi there,

Does anyone knows how to publish the service provider?

I would like to override the hydrate settings.

Thanks in advance

Maximum execution time of 30 seconds exceeded

Hi,

I try with:

$all = Countries::all();

I use:

Laravel 5.4 / PHP 7.0

The error:

(1/1) FatalErrorException
Maximum execution time of 30 seconds exceeded
in FileStore.php (line 66)

Why so long?

unzip error

david$ composer require pragmarx/countries
Using version ^0.1.1 for pragmarx/countries
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing commercie/currency (1.1.0): Downloading (100%)         
  - Installing symfony/yaml (v3.4.2): Downloading (100%)         
  - Installing mledoze/countries (1.8.0): Downloading (100%)         
  - Installing pragmarx/countries (v0.1.1): Downloading (100%)         
    Failed to execute unzip -qq  '/Users/david/Projects/sentry-defence/vendor/pragmarx/countries/36d386babf999bfe85247e40ed0e03c1' -d '/Users/david/Projects/sentry-defence/vendor/composer/5cdc8b03'

replace /Users/david/Projects/sentry-defence/vendor/composer/5cdc8b03/antonioribeiro-countries-7941fd2/tests/phpunit/ValidationTest.php? [y]es, [n]o, [A]ll, [N]one, [r]ename:  NULL
(EOF or read error, treating as "[N]one" ...)

    The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
    Unzip with unzip command failed, falling back to ZipArchive class
commercie/currency suggests installing drupal/currency (Integrates this package with Drupal.)
Writing lock file
Generating optimized autoload files

Looks like a case sensitivity issue

Running on macOS Sierra 10.12.6 (16G1036)

Not working on Laravel 5.4

Hi,
I'm encountering installation issues. Please see below:

composer require pragmarx/countries
Using version ^0.5.5 for pragmarx/countries
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install pragmarx/coollection v0.5.0
    - pragmarx/countries v0.5.5 requires pragmarx/coollection ~0.5 -> satisfiable by pragmarx/coollection[v0.5.0, v0.5.1, v0.5.2].
    - Conclusion: don't install pragmarx/coollection v0.5.2
    - Installation request for pragmarx/countries ^0.5.5 -> satisfiable by pragmarx/countries[v0.5.5].
    - Conclusion: remove laravel/framework v5.4.15
    - Installation request for symfony/var-dumper (locked at v3.2.6) -> satisfiable by symfony/var-dumper[v3.2.6].
    - Installation request for ramsey/uuid (locked at 3.5.2) -> satisfiable by ramsey/uuid[3.5.2].
    - Installation request for doctrine/inflector (locked at v1.1.0) -> satisfiable by doctrine/inflector[v1.1.0].
    - Conclusion: don't install laravel/framework v5.4.15
    - pragmarx/coollection v0.5.1 requires tightenco/collect >=5.5.33 -> satisfiable by illuminate/support[v5.5.33, v5.5.34, v5.6.0, v5.6.1, v5.6.2, v5.6.3], tightenco/collect[v5.5.33, v5.6.0].
    - don't install illuminate/support v5.5.33|don't install laravel/framework v5.4.15
    - don't install illuminate/support v5.5.34|don't install laravel/framework v5.4.15
    - don't install illuminate/support v5.6.0|don't install laravel/framework v5.4.15
    - don't install illuminate/support v5.6.1|don't install laravel/framework v5.4.15
    - don't install illuminate/support v5.6.2|don't install laravel/framework v5.4.15
    - don't install illuminate/support v5.6.3|don't install laravel/framework v5.4.15
    - don't install tightenco/collect v5.5.33|don't install laravel/framework v5.4.15
    - don't install tightenco/collect v5.6.0|don't install laravel/framework v5.4.15
    - Installation request for laravel/framework (locked at v5.4.15, required as 5.4.*) -> satisfiable by laravel/framework[v5.4.15].


Installation failed, reverting ./composer.json to its original content.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.