### Install Dependencies Source: https://github.com/rinvex/countries/wiki/1)-Installation Command to install or update project dependencies using Composer. ```bash composer install # or composer update ``` -------------------------------- ### PSR Coding Standards Source: https://github.com/rinvex/countries/blob/master/CONTRIBUTING.md This project adheres to PSR-1, PSR-2, and PSR-4 standards for PHP code quality and interoperability. These standards cover basic coding, style guides, and autoloading. ```php Follows PSR-1: Basic Coding Standard Follows PSR-2: Coding Style Guide Follows PSR-4: Autoloader ``` -------------------------------- ### Get Country Data Methods Source: https://github.com/rinvex/countries/blob/master/README.md Demonstrates various methods to retrieve specific data points for a country object, such as currency, translations, geodata, and extra information. ```php $egypt->getDataProtection(); $egypt->getNativeNames(); ``` ```php // {"iso_4217_code":"EGP","iso_4217_numeric":818,"iso_4217_name":"Egyptian Pound","iso_4217_minor_unit":2} $egypt->getCurrency(); ``` ```php // {"EGP":{"iso_4217_code":"EGP","iso_4217_numeric":818,"iso_4217_name":"Egyptian Pound","iso_4217_minor_unit":2}} $egypt->getCurrencies(); ``` ```php // {"ara":{"official":"جمهورية مصر العربية","common":"مصر"},"cym":{"official":"Arab Republic of Egypt","common":"Yr Aifft"},"deu":{"official":"Arabische Republik Ägypten","common":"Ägypten"},"fra":{"official":"République arabe d'Égypte","common":"Égypte"},"hrv":{"official":"Arapska Republika Egipat","common":"Egipat"},"ita":{"official":"Repubblica araba d'Egitto","common":"Egitto"},"jpn":{"official":"エジプト·アラブ共和国","common":"エジプト"},"nld":{"official":"Arabische Republiek Egypte","common":"Egypte"},"por":{"official":"República Árabe do Egipto","common":"Egito"},"rus":{"official":"Арабская Республика Египет","common":"Египет"},"spa":{"official":"República Árabe de Egipto","common":"Egipto"},"fin":{"official":"Egyptin arabitasavalta","common":"Egypti"}} $egypt->getTranslations(); ``` ```php // {"continent":{"AF":"Africa"},"postal_code":true,"latitude":"27 00 N","latitude_dec":"26.756103515625","longitude":"30 00 E","longitude_dec":"29.86229705810547","max_latitude":"31.916667","max_longitude":"36.333333","min_latitude":"20.383333","min_longitude":"24.7","area":1002450,"region":"Africa","subregion":"Northern Africa","world_region":"EMEA","region_code":"002","subregion_code":"015","landlocked":false,"borders":["ISR","LBY","SDN"],"independent":"Yes"} $egypt->getGeodata(); ``` ```php // {"geonameid":357994,"edgar":"H2","itu":"EGY","marc":"ua","wmo":"EG","ds":"ET","fifa":"EGY","fips":"EG","gaul":40765,"ioc":"EGY","cowc":"EGY","cown":651,"fao":59,"imf":469,"ar5":"MAF","address_format":"{{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}}","eu_member":null,"data_protection":"Other","vat_rates":null,"emoji":"🇪🇬"} $egypt->getExtra(); ``` ```php // {"name":"Al Iskandariyah","alt_names":["El Iskandariya","al-Iskandariyah","al-Iskandarīyah","Alexandria","Alexandrie","Alexandria"],"geo":{"latitude":31.2000924,"longitude":29.9187387,"min_latitude":31.1173177,"min_longitude":29.8233701,"max_latitude":31.330904,"max_longitude":30.0864016}} $egypt->getDivision("ALX"); ``` -------------------------------- ### Git Flow Branching Model Source: https://github.com/rinvex/countries/blob/master/CONTRIBUTING.md The project utilizes the Git Flow branching model. Pull requests should be submitted to the 'develop' branch. Key branches include 'master' for stable releases and 'develop' for ongoing development. ```git Branching Model: Git-Flow Main branches: master (stable), develop (WIP) Support branches: X.Y (for multiple major versions) Pull Requests: MUST be sent to the 'develop' branch. ``` -------------------------------- ### Get All Countries and Filtered Countries Source: https://github.com/rinvex/countries/blob/master/README.md Demonstrates how to retrieve all countries or filter them based on specific criteria, such as geographical continent. ```php // Get all countries $countries = countries(); // Get countries with where condition (continent: Oceania) $whereCountries = RinvexCountryCountryLoader::where('geo.continent', ['OC' => 'Oceania']); ``` -------------------------------- ### Get Single Country Details Source: https://github.com/rinvex/countries/blob/master/README.md Retrieves details for a specific country using its ISO alpha2 code. It provides access to various attributes of the country object. ```php $egypt = country('eg'); // Get country name echo $egypt->getName(); // Get country native name echo $egypt->getNativeName(); // Get country official name echo $egypt->getOfficialName(); // Get country ISO 3166-1 alpha2 code echo $egypt->getIsoAlpha2(); // Get country area echo $egypt->getArea(); // Get country borders echo $egypt->getBorders(); // Get country currencies echo $egypt->getCurrencies(); // Get country languages echo $egypt->getLanguages(); // Get country emoji echo $egypt->getEmoji(); // Get country flag echo $egypt->getFlag(); ``` -------------------------------- ### Composer Prerequisites Source: https://github.com/rinvex/countries/wiki/1)-Installation Specifies the PHP version and Illuminate support required for the Rinvex Countries package. ```json { "php": ">=5.5.9", "illuminate/support": "5.1.*|5.2.*|5.3.*" } ``` -------------------------------- ### Country Data Structure Explained Source: https://github.com/rinvex/countries/blob/master/README.md This section details the structure of the `countries.json` file, explaining each field and its nested properties. It covers country names (common, official, native), demonyms, capital cities, ISO codes (alpha-2, alpha-3, numeric), currency information, top-level domains, alternative spellings, languages, translations, geographical data, dialing codes, and various extra identifiers. ```json { "name": { "common": "string", "official": "string", "native": { "[lang_code]": { "official": "string", "common": "string" } } }, "demonym": "string", "capital": "string", "iso_3166_1_alpha2": "string", "iso_3166_1_alpha3": "string", "iso_3166_1_numeric": "string", "currency": { "[currency_code]": { "iso_4217_code": "string", "iso_4217_numeric": "string", "iso_4217_name": "string", "iso_4217_minor_unit": "integer" } }, "tld": [ "string" ], "alt_spellings": [ "string" ], "languages": { "[lang_code]": "string" }, "translations": { "[lang_code]": { "official": "string", "common": "string" } }, "geo": { "continent": { "[continent_code]": "string" }, "postal_code": "boolean", "latitude": "string", "latitude_desc": "string", "longitude": "string", "longitude_desc": "string", "max_latitude": "string", "max_longitude": "string", "min_latitude": "string", "min_longitude": "string", "area": "string", "region": "string", "subregion": "string", "world_region": "string", "region_code": "string", "subregion_code": "string", "landlocked": "boolean", "borders": [ "string" ], "independent": "boolean" }, "dialling": { "calling_code": [ "string" ], "national_prefix": "string", "national_number_lengths": [ "integer" ], "national_destination_code_lengths": [ "integer" ], "international_prefix": "string" }, "extra": { "geonameid": "integer", "edgar": "string", "itu": "string", "marc": "string", "wmo": "string", "ds": "string", "fifa": "string", "fips": "string", "gaul": "integer", "ioc": "string", "cowc": "string", "cown": "integer", "fao": "string", "imf": "string", "ar5": "string", "address_format": "string", "eu_member": "boolean", "data_protection": "string", "vat_rates": "string", "emoji": "string" } } ``` -------------------------------- ### Require Rinvex Countries Package Source: https://github.com/rinvex/countries/wiki/1)-Installation Adds the Rinvex Countries package to the composer.json file. ```json "rinvex/country": "1.0.*" ``` -------------------------------- ### Find All Countries Source: https://github.com/rinvex/countries/wiki/3)-Usage Retrieves all countries available in the package. Returns a collection of all matching countries. ```php $countries = (new Country)->findAll(); ``` -------------------------------- ### Native PHP Integration Source: https://github.com/rinvex/countries/wiki/2)-Integration Demonstrates how to integrate the Rinvex Countries package into a native PHP project by including the Composer autoloader. This allows direct access to the package's functionalities. ```php require __DIR__ . '/vendor/autoload.php'; ``` -------------------------------- ### Find Country by ISO Code Source: https://github.com/rinvex/countries/wiki/3)-Usage Finds a country using its ISO 3166-1 alpha-2 code. Returns an array containing the first matching country. ```php $egypt = (new Country)->find('EG'); ``` -------------------------------- ### Retrieve Country Attributes Source: https://github.com/rinvex/countries/blob/master/README.md This snippet demonstrates how to instantiate a country object and retrieve various attributes such as names, codes, geographical data, and regional information. It covers fetching native names, official names, demonyms, capital cities, ISO codes, TLDs, languages, continent, latitude, longitude, borders, calling codes, and more. ```php $egypt = country('eg'); // Egypt // مصر $egypt->getName(); $egypt->getNativeName(); // Arab Republic of Egypt // جمهورية مصر العربية $egypt->getOfficialName(); $egypt->getNativeOfficialName(); // Egyptian // Cairo $egypt->getDemonym(); $egypt->getCapital(); // EG // EGY $egypt->getIsoAlpha2(); $egypt->getIsoAlpha3(); // 818 // .eg $egypt->getIsoNumeric(); $egypt->getTld(); // [".eg",".مصر"] // ["EG","Arab Republic of Egypt"] $egypt->getTlds(); $egypt->getAltSpellings(); // Arabic // {"ara":"Arabic"} $egypt->getLanguage(); $egypt->getLanguages(); // Africa // true $egypt->getContinent(); $egypt->usesPostalCode(); // 27 00 N // 30 00 E $egypt->getLatitude(); $egypt->getLongitude(); // 26.756103515625 // 29.86229705810547 $egypt->getLatitudeDesc(); $egypt->getLongitudeDesc(); // 31.916667 // 36.333333 $egypt->getMaxLatitude(); $egypt->getMaxLongitude(); // 20.383333 // 24.7 $egypt->getMinLatitude(); $egypt->getMinLongitude(); // 1002450 // Africa $egypt->getArea(); $egypt->getRegion(); // Northern Africa // EMEA $egypt->getSubregion(); $egypt->getWorldRegion(); // 002 // 015 $egypt->getRegionCode(); $egypt->getSubregionCode(); // false // ["ISR","LBY","SDN"] $egypt->isLandlocked(); $egypt->getBorders(); // Yes // 20 $egypt->isIndependent(); $egypt->getCallingCode(); // ["20"] // 0 $egypt->getCallingCodes(); $egypt->getNationalPrefix(); // 9 // [9] $egypt->getNationalNumberLength(); $egypt->getNationalNumberLengths(); // 2 // [2] $egypt->getNationalDestinationCodeLength(); $egypt->getnationaldestinationcodelengths(); // "00" // {{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}} $egypt->getInternationalPrefix(); $egypt->getAddressFormat(); // 357994 // H2 $egypt->getGeonameid(); $egypt->getEdgar(); // EGY // ua $egypt->getItu(); $egypt->getMarc(); // EG // ET $egypt->getWmo(); $egypt->getDs(); // EGY // EG $egypt->getFifa(); $egypt->getFips(); // 40765 // EGY $egypt->getGaul(); $egypt->getIoc(); // EGY // 651 $egypt->getCowc(); $egypt->getCown(); // 59 // 469 $egypt->getFao(); $egypt->getImf(); // MAF // null $egypt->getAr5(); $egypt->isEuMember(); // null // 🇪🇸 $egypt->getVatRates(); $egypt->getEmoji(); // GeoJson data returned as string // SVG data returned as string $egypt->getGeoJson(); $egypt->getFlag(); // Divisions returned as array // {"official":"جمهورية مصر العربية","common":"مصر"} $egypt->getDivisions(); $egypt->getTranslation(); // ['Africa/Cairo'] // ['ar_EG'] $egypt->getTimezones(); $egypt->getLocales(); // Other // {"ara":{"official":"جمهورية مصر العربية","common":"مصر"}} ``` -------------------------------- ### Selective Attribute Retrieval and Collection Usage Source: https://github.com/rinvex/countries/wiki/Home Shows how to retrieve specific attributes of a country and how to use Laravel Collections for data manipulation, such as plucking specific values. ```php // Retrieve only `name`, `demonym`, and `currency` attributes of "Japan": $japan = (new Country)->find('JP', ['name', 'demonym', 'currency']); // Utilize Laravel Collections to get an array of all country names, with their 'iso_3166_1_alpha2' as the array keys (new Country)->findAll()->pluck('name.common', 'iso_3166_1_alpha2'); ``` -------------------------------- ### Basic Country Retrieval Source: https://github.com/rinvex/countries/wiki/Home Demonstrates how to find a country by its ISO 3166-1 alpha-2 code, by a specific attribute, or retrieve all countries. ```php use Rinvex\Country\Models\Country; // Find a country by it's ISO 3166-1 alpha-2 $egypt = (new Country)->find('EG'); // Find a country by one of it's attributes $usa = (new Country)->findBy('capital', 'Washington D.C.'); // Find all countries $countries = (new Country)->findAll(); ``` -------------------------------- ### Import Country Class Source: https://github.com/rinvex/countries/wiki/3)-Usage Imports the necessary Country class from the Rinvex package to begin using its functionalities. ```php use Rinvex\Country\Models\Country; ``` -------------------------------- ### Find Country with Specific Attributes Source: https://github.com/rinvex/countries/wiki/3)-Usage Finds a country by its ISO code and retrieves only specified attributes. This allows for targeted data retrieval. ```php $japan = (new Country)->find('JP', ['name', 'demonym', 'currency']); ``` -------------------------------- ### Find Country by Attribute Source: https://github.com/rinvex/countries/wiki/3)-Usage Finds a country by searching for a specific attribute and its value. Returns an array containing the first matching country. ```php $usa = (new Country)->findBy('capital', 'Washington D.C.'); ``` -------------------------------- ### Egypt Country Data Source: https://github.com/rinvex/countries/wiki/4)-Country-Example This snippet details the country information for Egypt (EG). It includes official and common names in Arabic and English, ISO 3166 codes, currency information (Egyptian Pound), geographical data like capital, coordinates, and borders, as well as dialing codes and address formatting. ```json { "EG": { "name": { "common": "Egypt", "official": "Arab Republic of Egypt", "native": { "ara": { "official": "جمهورية مصر العربية", "common": "مصر" } } }, "demonym": "Egyptian", "capital": "Cairo", "iso_3166_1_alpha2": "EG", "iso_3166_1_alpha3": "EGY", "iso_3166_1_numeric": "818", "currency": { "EGP": { "iso_4217_code": "EGP", "iso_4217_numeric": 818, "iso_4217_name": "Egyptian Pound", "iso_4217_minor_unit": 2 } }, "tld": [ ".eg", ".مصر" ], "alt_spellings": [ "EG", "Arab Republic of Egypt" ], "languages": { "ara": "Arabic" }, "translations": { "cym": { "official": "Arab Republic of Egypt", "common": "Yr Aifft" }, "deu": { "official": "Arabische Republik Ägypten", "common": "Ägypten" }, "fra": { "official": "République arabe d\'Égypte", "common": "Égypte" }, "hrv": { "official": "Arapska Republika Egipat", "common": "Egipat" }, "ita": { "official": "Repubblica araba d\'Egitto", "common": "Egitto" }, "jpn": { "official": "エジプト·アラブ共和国", "common": "エジプト" }, "nld": { "official": "Arabische Republiek Egypte", "common": "Egypte" }, "por": { "official": "República Árabe do Egipto", "common": "Egito" }, "rus": { "official": "Арабская Республика Египет", "common": "Египет" }, "spa": { "official": "República Árabe de Egipto", "common": "Egipto" }, "fin": { "official": "Egyptin arabitasavalta", "common": "Egypti" } }, "geo": { "continent": { "AF": "Africa" }, "postal_code": true, "latitude": "27 00 N", "latitude_dec": "26.756103515625", "longitude": "30 00 E", "longitude_dec": "29.86229705810547", "max_latitude": "31.916667", "max_longitude": "36.333333", "min_latitude": "20.383333", "min_longitude": "24.7", "area": 1002450, "region": "Africa", "subregion": "Northern Africa", "world_region": "EMEA", "region_code": "002", "subregion_code": "015", "landlocked": false, "borders": [ "ISR", "LBY", "SDN" ], "independent": "Yes" }, "dialling": { "calling_code": [ "20" ], "national_prefix": "0", "national_number_lengths": [ 9 ], "national_destination_code_lengths": [ 2 ], "international_prefix": "00" }, "extra": { "geonameid": 357994, "edgar": "H2", "itu": "EGY", "marc": "ua", "wmo": "EG", "ds": "ET", "fifa": "EGY", "fips": "EG", "gaul": 40765, "ioc": "EGY", "cowc": "EGY", "cown": 651, "fao": 59, "imf": 469, "ar5": "MAF", "address_format": "{{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}}", "eu_member": null, "vat_rates": null } } } ``` -------------------------------- ### Rinvex Countries Data Structure Source: https://github.com/rinvex/countries/wiki/5)-Features-Explained This entry details the complete data structure for country information within the Rinvex Countries package. It covers all available fields, their types, and nested structures for related data like names, currencies, and geographical coordinates. ```APIDOC CountryDataStructure: name: common: string - common name in english official: string - official name in english native: object - list of all native names key: string - three-letter ISO 639-3 language alpha code value: object - name object key: string - official - official name translation key: string - common - common name translation demonym: string - name of residents capital: string - capital city iso_3166_1_alpha2: string - code ISO 3166-1 alpha-2 iso_3166_1_alpha3: string - code ISO 3166-1 alpha-3 iso_3166_1_numeric: string - code ISO 3166-1 numeric currency: object - ISO 4217 currency code(s) key: string - three-letter ISO 4217 currency code value: object - currency object key: string - iso_4217_code - three-letter ISO 4217 currency alpha code key: string - iso_4217_numeric - three-number ISO 4217 currency numeric code key: string - iso_4217_name - official ISO 4217 currency name key: string - iso_4217_minor_unit - minor currency unit tld: string - country code top-level domain alt_spellings: array - alternative spellings languages: object - list of official languages key: string - three-letter ISO 639-3 language code value: string - name of the language in english translations: object - list of name translations key: string - three-letter ISO 639-3 language code value: object - name object key: string - official - official name translation key: string - common - common name translation geo: continent: object - continents that country lies in key: string - two-letter continent code value: string - name of the continent in english postal_code: boolean - geographical area postal code latitude: string - short form of latitude coordinate point latitude_dec: string - described latitude coordinate point longitude: string - short form of longitude coordinate point longitude_dec: string - described longitude coordinate point max_latitude: string - maximum latitude coordinate point max_longitude: string - maximum longitude coordinate point min_latitude: string - minimum latitude coordinate point min_longitude: string - minimum longitude coordinate point area: number - land area in km² region: string - geographical region subregion: string - geographical sub-region world_region: string - geographical world region region_code: string - geographical region numeric code subregion_code: string - geographical sub-region numeric code landlocked: boolean - landlocked status borders: array - land borders independent: boolean - independent status dialling: calling_code: array - calling code(s) national_prefix: string - national prefix national_number_lengths: array - national number lengths national_destination_code_lengths: array - national destination code lengths international_prefix: string - international prefix extra: geonameid: integer - Geoname ID edgar: string - Electronic Data Gathering, Analysis, and Retrieval system itu: string - Codes assigned by the International Telecommunications Union marc: string - MAchine-Readable Cataloging codes from the Library of Congress wmo: string - Country abbreviations by the World Meteorological Organization ds: string - Distinguishing signs of vehicles in international traffic fifa: string - Codes assigned by the Fédération Internationale de Football Association fips: string - Codes from the U.S. Federal Information Processing Standard gaul: string - Global Administrative Unit Layers from the Food and Agriculture Organization ioc: string - Codes assigned by the International Olympics Committee cowc: string - Correlates of War character cown: string - Correlates of War numeric fao: string - Food and Agriculture Organization imf: string - International Monetary Fund ar5: string - Fifth Assessment Report (AR5) address_format: string - Address format eu_member: boolean - European Union Member vat_rates: array - Value-Added Tax ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.