delboy1978uk / country
A PHP library of countries and flags.
Installs: 2 373
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: ^8.2
- delboy1978uk/image: ^2.6
Requires (Dev)
- codeception/codeception: ^5.1
- codeception/module-asserts: ^3.0
- roave/security-advisories: dev-latest
README
A countries and flags library in PHP.
installation
Install via composer into your project:
composer require delboy1978uk/country
usage
factory
You can call CountryFactory::generate($code)
to create a country object
public static function generate(string $id): Country;
entity
public function __toString(); public function getFlag(): string; public function getId(): string; public function getIso(): string; public function getName(): string; public function getNumCode(): int; public function setFlag(string $flag): void; public function setId(string $id): void public function setIso(string $iso): void; public function setName(string $name): void; public function setNumCode(int $numCode): void; public function toArray(): array;
trait
You can use HasCountryTrait
to add a country to your object (also works with doctrine)
public function getCountry(): Country; public function setCountry(Country $country): void;
flag image helper
You can call Flag::render($country, $size)
, where size can be one of tiny, small, medium, or large
.
public static function render(Country $country, $size)