The PHP Continents Package provides a convenient and object-oriented approach to working with continent data. Designed to integrate continent information into any PHP applications with ease. This package offers easy access to continent names, non-standardized alpha-2 codes and UN M.49 numeric codes. Eventually, more detailed geographical data is coming like subregions and extra locales.
- Easy retrieval of continent names and codes.
- Object-Oriented Programming (OOP) approach for better data management and integration.
- Lightweight and simple to integrate into any PHP project. (8.1+)
- Currently supporting English, Hungarian, German, Spanish, Italian and French languages.
- Future support for subregions and multiple locales, making it versatile for international applications.
The PHP Continents Package can be easily installed via Composer.
composer require omisai/php-continents
After installing the package, you can begin to work with continent data. You can work with any continent model or access all of them through a Collection.
/**
* Access through the Collection
*
* Consider using the Collection class, if you
* plan to register it to a service container.
* It eagerly loads all the continents.
*/
use Omisai\Continents\Collection;
$collection = new Collection();
$continents = $collection->getContinents();
/**
* Shorthand to use the default english locale
*/
$continents[0]->name; // "Asia"
/**
* Or using different locale
*/
$continents[0]->getName('fr'); // "Asie"
/**
* Search for continent based on alpha-2 code
*/
$collection->getContinentByCode('OC'); // Omisai\Continents\Models\Oceania
/**
* Search for continent based on UN M.49 numeric code
*/
$collection->getContinentByNumeric('010'); // Omisai\Continents\Models\Antarctica
/**
* Use any continent directly
*/
use Omisai\Continents\Models\Europe;
$europe = new Europe();
$europe->numeric; // "150"
$europe->code; // "EU"
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
./vendor/bin/pest
# or
composer test
If you discover any security-related issues, please email security@omisai.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.