Geographer is a PHP library that knows how any country, state or city is called in any language

Overview

Geographer

Build Status Code Climate Test Coverage Total Downloads Latest Stable Version Latest Unstable Version License

Geographer is a PHP library that knows how any country, state or city is called in any language. Documentation on the official website

Includes integrations with: Laravel 5, Lumen 5

Geographer

Dependencies

  • PHP >= 5.5

Installation via Composer

To install simply run:

$ composer require menarasolutions/geographer

Or add it to composer.json manually:

{
    "require": {
        "menarasolutions/geographer": "~0.3"
    }
}

This, main package is shipped with English language so add extra dependencies for your other languages, eg.:

$ composer require menarasolutions/geographer-es

Usage

use MenaraSolutions\Geographer\Earth;
use MenaraSolutions\Geographer\Country;

// Default entry point is our beautiful planet
$earth = new Earth();

// Give me a list of all countries please
$earth->getCountries()->toArray();

// Oh, but please try to use short versions, eg. USA instead of United States of America
$earth->getCountries()->useShortNames()->toArray();

// Now please give me all states of Thailand
$thailand = $earth->getCountries()->findOne(['code' => 'TH']); // You can call find on collection
$thailand = $earth->findOne(['code' => 'TH']); // Or right away on division
$thailand = $earth->findOneByCode('TH'); // Alternative shorter syntax
$thailand = Country::build('TH'); // You can build a country object directly, too
$thailand->getStates()->toArray();

// Oh, but I want them in Russian
$thailand->getStates()->setLocale('ru')->toArray();

// Oh, but I want them inflicted to 'in' form (eg. 'in Spain')
$thailand->getStates()->setLocale('ru')->inflict('in')->toArray();

// Or if you prefer constants for the sake of IDE auto-complete
$thailand->getStates()->setLocale(TranslationAgency::LANG_RUSSIAN)->inflict(TranslationAgency::FORM_IN)->toArray();

// What's the capital and do you have a geonames ID for that? Or maybe latitude and longitude?
$capital = $thailand->getCapital();
$capital->getGeonamesCode();
$capital->getLatitude();
$capital->getLongitude();

Collections

Arrays of administrative divisions (countries, states or cities) are returned as collections – a modern way of implementing arrays. Some of the available methods are:

$states->sortBy('name'); // States will be sorted by name
$states->setLocale('ru')->sortBy('name'); // States will be sorted by Russian translations/names
$states->find(['code' => 472039]); // Find 1+ divisions that match specified parameters 
$states->findOne(['code' => 472039]); // Return the first match only
$states->findOneByCode(472039); // Convenience magic method
$states->toArray(); // Return a flat array of states
$states->pluck('name'); // Return a flat array of state names

Common methods on division objects

All objects can do the following:

$object->toArray(); // Return a flat array with all data
$object->parent(); // Return a parent (city returns a state, state returns a country)
$object->getCode(); // Get default unique ID
$object->getShortName(); // Get short (colloquial) name of the object
$object->getLongName(); // Get longer name
$object->getCodes(); // Get a plain array of all available unique codes

You can access information in a number of ways, do whatever you are comfortable with:

$object->getName(); // Get object's name (inflicted and shortened when necessary)
$object->name; // Same effect
$object['name']; // Same effect
$object->toArray()['name']; // Same effect again

Subdivision standards

By default, we will use ISO-3166-1 country and ISO 3166-2 state classification. Therefore, countries or states that don't have ISO codes are not visible by default. Please note that FIPS 10-4 is a deprecated (abandoned) standard. It's better not to rely on it – new states and/or countries won't appear in FIPS.

You can change subdivision standard with setStandard method:

$country->setStandard(DefaultManager::STANDARD_ISO); // ISO subdivisions
$country->setStandard(DefaultManager::STANDARD_FIPS); // FIPS 10-4 subdivisions
$country->setStandard(DefaultManager::STANDARD_GEONAMES); // Geonames subdivisions

This will affect getStates() and getCountries() output.

Earth API

Earth object got the following convenience methods:

$earth->getAfrica(); // Get a collection of African countries
$earth->getEurope(); // Get a collection of European countries
$earth->getNorthAmerica(); // You can guess
$earth->getSouthAmerica(); 
$earth->getAsia();
$earth->getOceania();

$earth->getCountries(); // A collection of all countries
$earth->withoutMicro(); // Only countries that have population of at least 100,000

By default, we will use ISO 3166-1 country classification.

Country API

Country objects got the following encapsulated data:

$country->getCode(); //ISO 3166-1 alpha-2 (2 character) code
$country->getCode3(); // ISO 3166-1 alpha-3
$country->getNumericCode(); // ISO 3166-1 numeric code
$country->getGeonamesCode(); // Geonames ID
$country->getFipsCode(); // FIPS code
$country->getArea(); // Area in square kilometers
$country->getCurrencyCode(); // National currency, eg. USD
$country->getPhonePrefix(); // Phone code, eg. 7 for Russia
$country->getPopulation(); // Population
$country->getLanguage(); // Country's first official language

$country->getStates(); // A collection of all states
Country::build('TH'); // Build a country object based on ISO code

Geonames, ISO 3166-1 alpha-2, alpha-3 and numeric codes are four viable options to reference country in your data store.

State API

At this moment Geographer only keeps cities with population above 50,000 for the sake of performance.

$state->getCode(); // Get default code (currently Geonames)
$state->getIsoCode(); // Get ISO 3166-2 code  
$state->getFipsCode(); // Get FIPS code
$state->getGeonamesCode(); // Get Geonames code

$state->getCities(); // A collection of all cities
$state = State::build($id); // Instantiate a state directly, based on $id provided (Geonames or ISO)

Geonames, ISO 3166-2 and FIPS are all unique codes so all three can be used to reference states in your data store.

City API

$city->getCode(); // This is always a Geonames code for now
$city = City::build($id); // Instantiate a city directly, based on $id provided (Geonames) 
$city->getLatitude(); // City's latitude
$city->getLongitude(); // City's longitude
$city->getPopulation(); // Population

Geonames ID is currently the only viable option to reference a city in your data store.

Integrations with frameworks

Official Laravel package

Current coverage: subdivisions

Type ISO 3166 FIPS Geonames GENC
Countries 100% Coming soon 100% TBC
States 100% Coming soon 100% TBC

Subdivision data is kept in a separate repo - geographer-data so that it may be reused by different language SDKs.

Current coverage: translations

By default Geographer assumes that you use Packagist (Composer) to install language packages, therefore we will expect them in vendor/ folder. There is no need to manually turn on an extra language, but if you attempt to use a non-existing language – expect an exception.

Language Countries States Cities Package
English 100% 100% 100% geographer-data
Russian 100% 100% 63% geographer-ru
Ukrainian geographer-uk
Spanish geographer-es
Italian geographer-it
French geographer-fr
German geographer-de
Chinese Mandarin geographer-zh
Danish - - geographer-da

English texts are included in the data package and are used as default metadata.

Vision

Our main principles and goals are:

  1. Be lightweight and independent – so that this package can be pulled anywhere alone
  2. Coverage – Geographer should cover all countries and languages
  3. Be extensible – developers should be able to override and extend easily

Performance

While not a number one priority at this stage, we will try maintain reasonable CPU and memory performance. Some benchmarks:

Inflating a city based on its Id

Time: 6 ms, memory: 81056 bytes

Video tutorials

I've just started a educational YouTube channel that will cover top IT trends in software development and DevOps: config.sys

Todo

  1. Add a basic spatial index
  2. Add some unit tests (in addition to existing integration tests)
  3. Add coverage information for language packages

Projects using Geographer

Tell us about yours!

Contribution

Read our Contribution guide

License

The MIT License (MIT) Copyright (c) 2016 Denis Mysenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • PHP 8.1 Errors

    PHP 8.1 Errors

    Output:

    PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of MenaraSolutions\Geographer\Divisible::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

    opened by juanfelipepipen 4
  • Why in MenaraSolutions/geographer plugin I can not get info on USA capital?

    Why in MenaraSolutions/geographer plugin I can not get info on USA capital?

    In Laravel 8 I with https://github.com/MenaraSolutions/geographer I need to get capital and its lat/lng of any country, but I failed to get it with code:

    $selectedCountry = $earth->getCountries()->setLocale('en')->findOne(['code' => strtoupper($next_country_key)]);
    \Log::info(  varDump($selectedCountry, ' -1 $selectedCountry::') );
    $capital = $selectedCountry->getCapital();
    \Log::info(  varDump($capital, ' -1 $capital::') );
    $countriesArray[] = [
        'label' => $next_country_label,
        'value' => $next_country_key,
        'geonames_code' => $capital->getGeonamesCode(),
        'lat' => $capital->getLatitude(),
        'lng' => $capital->getLongitude(),
    ];
    

    I got error :

    Call to a member function getGeonamesCode() on bool 
    

    as

    $selectedCountry->getCapital() 
    

    returned false.

    Checking in log content of $selectedCountry var I see:

    [2021-04-09 07:26:49] local.INFO:  (Object of MenaraSolutions\Geographer\Country) : -1 $selectedCountry:: : Array
    (
        [ * memberClass] => MenaraSolutions\Geographer\State
        [ * exposed] => Array
            (
                [code] => ids.iso_3166_1.0
                [code3] => ids.iso_3166_1.1
                [isoCode] => ids.iso_3166_1.0
                [numericCode] => ids.iso_3166_1.2
                [geonamesCode] => ids.geonames
                [fipsCode] => ids.fips
                [0] => area
                [1] => currency
                [phonePrefix] => phone
                [2] => mobileFormat
                [3] => landlineFormat
                [4] => trunkPrefix
                [5] => population
                [6] => continent
                [language] => languages.0
                [7] => name
            )
    
        [ * meta] => Array
            (
                [languages] => Array
                    (
                        [0] => en
                    )
    
                [ids] => Array
                    (
                        [iso_3166_1] => Array
                            (
                                [0] => US
                                [1] => USA
                                [2] => 840
                            )
    
                        [fips] => US
                        [geonames] => 6252001
                    )
    
                [long] => Array
                    (
                        [default] => United States of America
                    )
    
                [short] => Array
                    (
                        [default] => United States
                    )
    
                [area] => 9629091
                [currency] => USD
                [phone] => 1
                [trunkPrefix] => 1
                [landLineFormat] => [2-9]\d{9}
                [mobileFormat] => [2-9]\d{9}
                [continent] => NA
                [population] => 310232863
            )
    
        [ * members] => 
        [ * manager] => MenaraSolutions\Geographer\Services\DefaultManager Object
            (
                [translator:protected] => MenaraSolutions\Geographer\Services\TranslationAgency Object
                    (
                        [basePath:protected] => /mnt/_work_sdb8/wwwroot/lar/tAdsBack/vendor/menarasolutions/geographer/resources/
                        [repository:protected] => MenaraSolutions\Geographer\Repositories\File Object
                            (
                                [prefix:protected] => /mnt/_work_sdb8/wwwroot/lar/tAdsBack/vendor/menarasolutions/geographer-data/resources
                                [translationsPrefix:protected] => /mnt/_work_sdb8/wwwroot/lar/tAdsBack/vendor/menarasolutions
                                [cache:protected] => Array
                                    (
                                    )
    
                            )
    
                        [form:protected] => default
                        [inflictsTo:protected] => Array
                            (
                            )
    
                        [prepositions:protected] => 1
                        [languages:protected] => Array
                            (
                                [ru] => MenaraSolutions\Geographer\Services\Poliglottas\Russian
                                [en] => MenaraSolutions\Geographer\Services\Poliglottas\English
                                [es] => MenaraSolutions\Geographer\Services\Poliglottas\Spanish
                                [it] => MenaraSolutions\Geographer\Services\Poliglottas\Italian
                                [fr] => MenaraSolutions\Geographer\Services\Poliglottas\French
                                [zh] => MenaraSolutions\Geographer\Services\Poliglottas\Mandarin
                                [uk] => MenaraSolutions\Geographer\Services\Poliglottas\Ukrainian
                                [de] => MenaraSolutions\Geographer\Services\Poliglottas\German
                                [nl] => MenaraSolutions\Geographer\Services\Poliglottas\Dutch
                            )
    
                        [translators:protected] => Array
                            (
                            )
    
                    )
    
                [repository:protected] => MenaraSolutions\Geographer\Repositories\File Object
                    (
                        [prefix:protected] => /mnt/_work_sdb8/wwwroot/lar/tAdsBack/vendor/menarasolutions/geographer-data/resources
                        [translationsPrefix:protected] => /mnt/_work_sdb8/wwwroot/lar/tAdsBack/vendor/menarasolutions
                        [cache:protected] => Array
                            (
                            )
    
                    )
    
                [language:protected] => en
                [form:protected] => 
                [standard:protected] => iso
                [brief:protected] => 1
                [prepositions:protected] => 1
                [path:protected] => /mnt/_work_sdb8/wwwroot/lar/tAdsBack/vendor/menarasolutions/geographer/resources/
            )
    
        [ MenaraSolutions\Geographer\Divisible parent] => 
        [ * parentCode] => SOL-III
        [ * standard] => 
    )
    

    Does this package have no info on USA capital or something wrong in my code? I followed docs on github page...

    "menarasolutions/geographer": "^0.3.9",
    "menarasolutions/geographer-laravel": "^0.2.1",
    "laravel/framework": "^8.12",
    

    Thanks!

    opened by sergeynilov 3
  • Как получить объект города по его названию?

    Как получить объект города по его названию?

    Здравствуйте. У меня будет входной параметр - только название города на английском языке, полное. Как по нему получить объект города? Что-то не нашел такой возможности.

    opened by Alexell 2
  • feature: danish translation

    feature: danish translation

    our team would like to contribute the danish translations. If you are interested, can you create the geographer-da repository with the english text and we create a PR with the translations?

    or are there other ways on how to provide you with the needed information?

    opened by slaubi 2
  • Fails to load data if project is in a folder called

    Fails to load data if project is in a folder called "code"

    https://github.com/MenaraSolutions/geographer/blob/1f15dde4be9b5eb0222871e159ffc99621b26942/src/Repositories/File.php#L87

    It took me quite some time to figure out why the libery was failing to load any data on some systems. Please restrict the search replace to the data namespace folder.

    opened by AJenbo 2
  • Fix translations for Belarusian states.

    Fix translations for Belarusian states.

    Hello. I've fixed some translations in "ru.json". Of course, if all those names were pulled automatically from Geonames then my changes do not make any sense.

    opened by GinoPane 2
  • :bug: incorrect return type PHP 8.1

    :bug: incorrect return type PHP 8.1

    Hi @dusterio , Thanks for quickly merging my PR! Unfortunately there was one minor bug I introduced by specifying the incorrect return type; mixed should have been void - After this it is no longer triggering any code notices on PHP 8.1+.

    opened by xoref 1
  • Php8.1 errors

    Php8.1 errors

    This PR requires PHP >= 8.0 becaue of the new mixed return type

    • it fixes the following PHP 8.1.* code warnings:
    Undefined: Return type of MenaraSolutions\Geographer\Divisible::offsetGet($offset) should either be 
    compatible with ArrayAccess::offsetGet(mixed $offset): mixed, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Traits/ExposesFields.php #25
    
    Undefined: Return type of MenaraSolutions\Geographer\Divisible::offsetSet($offset, $value) should either be 
    compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Traits/ExposesFields.php #37
    
    Undefined: Return type of MenaraSolutions\Geographer\Divisible::offsetUnset($offset) should either be 
    compatible with ArrayAccess::offsetUnset(mixed $offset): void, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Traits/ExposesFields.php #46
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::getIterator() should either be 
    compatible with ArrayObject::getIterator(): Iterator, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #14
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::offsetExists($offset) should either be 
    compatible with ArrayObject::offsetExists(mixed $key): bool, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #22
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::offsetGet($offset) should either be 
    compatible with ArrayObject::offsetGet(mixed $key): mixed, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #31
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::offsetSet($offset, $value) should either be 
    compatible with ArrayObject::offsetSet(mixed $key, mixed $value): void, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #41
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::offsetUnset($offset) should either be 
    compatible with ArrayObject::offsetUnset(mixed $key): void, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #50
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::count() should either be 
    compatible with ArrayObject::count(): int, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #58
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::serialize() should either be 
    compatible with ArrayObject::serialize(): string, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #66
    
    Undefined: Return type of MenaraSolutions\Geographer\Collections\Traits\ImplementsArray::unserialize($serialized) should either be 
    compatible with ArrayObject::unserialize(string $data): void, 
    or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    in /.../vendor/menarasolutions/geographer/src/Collections/Traits/ImplementsArray.php #74
    
    opened by xoref 1
  • Arabic Translation Support

    Arabic Translation Support

    Our team would like to contribute to the translation into Arabic. If you are interested, can you create a "geographer-ar" repository using English translation, so that we can create a PR with Arabic translations?

    opened by ZedanLab 1
  • Change Divisible::build DocBlock return statement

    Change Divisible::build DocBlock return statement

    The DocBlock comment on the build method suggests only a City will be returned, when it can be a City, Country or State.

    It could maybe be changed to Divisable but that isn't as helpful, I have also ommitted Earth as a return type as for now I don't think people will be using this for other planets.

    opened by willishq 1
  •  add method merge

    add method merge

    Еще 1 полезный метод для коллекций.

    Используется например когда нужно вывести список всех городов страны, так как напрямую это сделать нельзя - приходится мержить списки городов всех регионов.


    One more useful method for collections.

    It can be used to display all cities of the country when you have to merge cities of all regions.

    opened by Xmk 1
  • [BUG]: State::build() with states/divisions with a single character

    [BUG]: State::build() with states/divisions with a single character

    Hello!

    • Type: bug fix
    • Link to issue: https://github.com/MenaraSolutions/geographer/issues/51

    Small description of change: Trying to look up states with only one character currently throws.

    Thanks

    opened by LlamaDuckGoose 0
  • [BUG]: State::build() with states/divisions with a single character

    [BUG]: State::build() with states/divisions with a single character

    Describe the bug Currently if you try to use State::Build() this will fail when the state/division has a single character. e.g. Bangladesh - Dhaka

    To Reproduce Steps to reproduce the behavior:

    $country = 'BD';
    $state = 'C';
    
    $meta = State::build("{$country}-{$state}")->getMeta();
    

    This will throw: MenaraSolutions\Geographer\Exceptions\ObjectNotFoundException Cannot find object with id BD-C

    opened by LlamaDuckGoose 1
  • France regions (getState()) returns deprecated ISO 3166-2 codes

    France regions (getState()) returns deprecated ISO 3166-2 codes

    The data for france regions was valid until 2015 and looked like this: Elsass (Alsace) | (FR-A)

    with a total of 22 regions.

    2016 there was a change to three letter codes and only 13 regions like this: Auvergne-Rhône-Alpes | FR-ARA

    [see https://de.wikipedia.org/wiki/ISO_3166-2:FR]

    opened by ksxentral 2
  • Why method Country->getCapital does not work with  v0.3.10 ?

    Why method Country->getCapital does not work with v0.3.10 ?

    Hello, About a month ago I wrote that method Country->getCapital does not work.

    At branch https://github.com/MenaraSolutions/geographer/issues/40 I got feedback :

    I took a look and it turns out this part was never finished properly :) I fixed the method in the code and added a test, but somebody has to make a pull request on geographer-data repo - edit resources/cities/*.json files adding "capital" property to the corresponding entries, eg: "long": { "default": "Moscow" }, "capital": true,

    Now I have the same problem . I page : https://github.com/MenaraSolutions/geographer/releases/tag/v0.3.10

    Fix get capital method @dusterio dusterio released this 22 days ago

    v0.3.10

    In composer.json I modified version of the package and now it has content :

    {
        "name": "laravel/laravel",
        "type": "project",
        "description": "The Laravel Framework.",
        "keywords": [
            "framework",
            "laravel"
        ],
        "license": "MIT",
        "require": {
            "php": "^7.3|^8.0",
            "cviebrock/eloquent-sluggable": "^8.0",
            "drewm/mailchimp-api": "^2.5",
            "fideloper/proxy": "^4.4",
            "fruitcake/laravel-cors": "^2.0",
            "guzzlehttp/guzzle": "^7.0.1",
            "jenssegers/agent": "^2.6",
            "laravel/fortify": "^1.7",
            "laravel/framework": "^8.12",
            "laravel/sanctum": "^2.8",
            "laravel/socialite": "^5.2",
            "laravel/tinker": "^2.5",
            "laravelcollective/html": "^6.2",
            "maatwebsite/excel": "^3.1",
            "mailchimp/mailchimp": "^2.0",
            "menarasolutions/geographer": "^0.3.10",
            "mews/purifier": "^3.3",
            "mobiledetect/mobiledetectlib": "^2.8",
            "monarobase/country-list": "^3.2",
            "spatie/browsershot": "^3.40",
            "spatie/emoji": "^2.2",
            "spatie/geocoder": "^3.10",
            "spatie/laravel-image-optimizer": "^1.6",
            "spatie/laravel-permission": "^4.0",
            "stidges/laravel-country-flags": "^2.0",
            "stripe/stripe-php": "^7.75",
            "toin0u/geocoder-laravel": "^4.4",
            "wboyz/laravel-enum": "^0.2.1",
            "webpatser/laravel-uuid": "^3.0"
        },
        "require-dev": {
            "facade/ignition": "^2.5",
            "fakerphp/faker": "^1.9.1",
            "laravel-frontend-presets/tailwindcss": "^4.3",
            "laravel/sail": "^1.0.1",
            "mockery/mockery": "^1.4.2",
            "nunomaduro/collision": "^5.0",
            "phpunit/phpunit": "^9.3.3"
        },
        "config": {
            "optimize-autoloader": true,
            "preferred-install": "dist",
            "sort-packages": true
        },
        "extra": {
            "laravel": {
                "dont-discover": []
            }
        },
        "autoload": {
            "files": [
                "app/library/helper.php"
            ],
            "psr-4": {
                "App\\": "app/",
                "Database\\Factories\\": "database/factories/",
                "Database\\Seeders\\": "database/seeders/"
            }
        },
        "autoload-dev": {
            "psr-4": {
                "Tests\\": "tests/"
            }
        },
        "minimum-stability": "dev",
        "prefer-stable": true,
        "scripts": {
            "post-autoload-dump": [
                "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
                "@php artisan package:discover --ansi"
            ],
            "post-root-package-install": [
                "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
            ],
            "post-create-project-cmd": [
                "@php artisan key:generate --ansi"
            ]
        }
    }
    
    

    I run commands :

    
    php artisan config:cache
    php artisan route:cache
    php artisan cache:clear
    php artisan view:clear
    php artisan  clear-compiled
    
    composer dump-autoload
    
    
    

    and removed “/vendor” and “/composer.lock” and run composer install and after that example from docs:

            $thailand = $earth->getCountries()->findOne(['code' => 'TH']);
            $capital = $thailand->getCapital(); // return NULL
    
    

    I do not if pull request on geographer-data repo was done, but with "menarasolutions/geographer": "^0.3.10" I expected this method woul work properly.

    How can I make it working?

    Thanks!

    opened by sergeynilov 0
  • Cannot find object with id at ../vendor/menarasolutions/geographer/src/Repositories/File.php:190)

    Cannot find object with id at ../vendor/menarasolutions/geographer/src/Repositories/File.php:190)

    I don't see any problems in work. But I have an error in the logs:

    Cannot find object with id {"userId":109,"exception":"[object] (MenaraSolutions\Geographer\Exceptions\ObjectNotFoundException(code: 0): Cannot find object with id at /var/www/site.com/main/vendor/menarasolutions/geographer/src/Repositories/File.php:190) [stacktrace] #0 /var/www/site.com/main/vendor/menarasolutions/geographer/src/Repositories/File.php(203): MenaraSolutions\Geographer\Repositories\File->getCodeFromIndex() #1 /var/www/site.com/main/vendor/menarasolutions/geographer/src/Divisible.php(203): MenaraSolutions\Geographer\Repositories\File->indexSearch() #2 /var/www/site.com/main/app/Models/Geography.php(119): MenaraSolutions\Geographer\Divisible::build() #3 /var/www/site.com/main/app/Http/Controllers/GeographyController.php(116): App\Models\Geography::cities() #4 [internal function]: App\Http\Controllers\GeographyController->reqCities() ....

    opened by mkswebdev 0
  • Test enhancement

    Test enhancement

    Changed log

    • Since the php-5.x versions are inactive for about long time. Using the php-7.x versions is fine.
    • Letting the build/ folder be under .gitignore file because this file is generated by PHPUnit.
    • Using the PHPUnit\Framework\TestCase namespace to be compatible with future PHPUnit versions.
    • The PHPUnit fixtures are about setUp and tearDown methods are protected.
    • Using assertCount to assert expected length is same as result count.
    • Using the assertInternalType to assert expected is array type.
    • The --dev option is deprecated when executing composer install command. The deprecated warning message is as follows:
    You are using the deprecated option "dev". Dev packages are installed by default now.
    
    opened by peter279k 0
Releases(v0.3.13)
Owner
Menara Solutions
A boutique web studio in Melbourne
Menara Solutions
[virion] Language management library for automatic translation

libtranslator :: library for automatic translation ✔️ Multilingual support for plugin messages ✔️ Translation language is set according to the player

PocketMine-MP projects of PresentKim 5 Jul 29, 2022
A morphological solution for Russian and English language written completely in PHP.

Morphos A morphological solution for Russian and English language written completely in PHP. Tests & Quality: Features [✓] Inflection of Personal name

Sergey 723 Jan 4, 2023
Language files manager in your artisan console.

Laravel Langman Langman is a language files manager in your artisan console, it helps you search, update, add, and remove translation lines with ease.

Mohamed Said 867 Nov 30, 2022
Support multiple language resources for Laravel

Laratrans Support multiple language resources for Laravel. Docs Installation composer require lechihuy/laratrans After you install the package success

Lê Chí Huy 3 Dec 21, 2021
PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)

Gettext Note: this is the documentation of the new 5.x version. Go to 4.x branch if you're looking for the old 4.x version Created by Oscar Otero http

Gettext 651 Dec 29, 2022
A PHP internationalization library, powered by CLDR data.

intl A PHP 7.1+ internationalization library, powered by CLDR data. Features: NumberFormatter and CurrencyFormatter, inspired by intl. Currencies Lang

Commerce Guys 351 Dec 30, 2022
🗓 A library to help you work with dates in multiple languages, based on Carbon.

Date This date library extends Carbon with multi-language support. Methods such as format, diffForHumans, parse, createFromFormat and the new timespan

Jens Segers 1.8k Dec 30, 2022
Patchwork UTF-8 for PHP: Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP

Patchwork UTF-8 for PHP Patchwork UTF-8 gives PHP developpers extensive, portable and performant handling of UTF-8 and grapheme clusters. It provides

Nicolas Grekas 80 Sep 28, 2022
A convenience package for php multilingual web applications

PHP Translation Install Lifecycle Configuration Content of PHP File Content of Json File Content Of Database Table Use Of Array Or Json Database PHP T

Ahmet Barut 3 Jul 7, 2022
FBT - a internationalization framework for PHP designed to be not just powerful and flexible, but also simple and intuitive

FBT is an internationalization framework for PHP designed to be not just powerful and flexible, but also simple and intuitive. It helps with the follo

Richard Dobroň 4 Dec 23, 2022
Composer package providing translation features for PHP apps

PHP translation This is a composer package providing translation support for PHP applications. It is similar to gettext, in usage, with these differen

Sérgio Carvalho 0 Aug 15, 2022
GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn

GeoLocation in PHP (API) ?? ?? ?? This package helps you to know a lot of information about the current user by his ip address ?? ?? ?? This package h

Abdullah Karam 4 Dec 8, 2022
IP2Location Yii extension enables the user to find the country, region, city, coordinates, zip code, time zone, ISP

IP2Location Yii extension enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, IP address type and IAB advertising category from IP address using IP2Location database. It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Location BIN databases or web service for applications written using Yii.

IP2Location 7 May 21, 2022
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
A simple class that provides access to country & state list.

GeoData A simple class that provides access to country & state list. Installation composer require ahmard/geodata Usage Fetch country list <?php use

Ahmad Mustapha 4 Jun 20, 2022