-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7728c3d
commit 0bbbe04
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
[![Latest Stable Version](http://poser.pugx.orgomisai/php-continents/v)](https://packagist.org/packagesomisai/php-continents) | ||
[![Latest Unstable Version](http://poser.pugx.orgomisai/php-continents/v/unstable)](https://packagist.org/packagesomisai/php-continents) | ||
[![License](http://poser.pugx.orgomisai/php-continents/license)](https://packagist.org/packagesomisai/php-continents) | ||
[![PHP Version Require](http://poser.pugx.orgomisai/php-continents/require/php)](https://packagist.org/packagesomisai/php-continents) | ||
|
||
# PHP Continents Package | ||
|
||
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. | ||
|
||
## Features | ||
|
||
- 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. | ||
|
||
## Installation | ||
|
||
The PHP Continents Package can be easily installed via Composer. | ||
|
||
```bash | ||
composer require omisai/php-continents | ||
``` | ||
|
||
## Usage | ||
|
||
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. | ||
|
||
```php | ||
|
||
/** | ||
* 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" | ||
|
||
``` | ||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Testing | ||
|
||
```bash | ||
./vendor/bin/pest | ||
|
||
# or | ||
|
||
composer test | ||
``` | ||
|
||
|
||
## Security | ||
|
||
If you discover any security-related issues, please email [security@omisai.com](mailto:security@omisai.com) instead of using the issue tracker. | ||
|
||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |