Monday 27 May 2019

Country Package for Laravel

It is often or not we need a country listing in our package to display in the view or dropdown HTML component. Instead of creating table of coutries we could use a proven PHP package library to do that.

I come across this library league/iso3166 and have use it ever since.

Methods you can use are:


   #to define the library 
   use League\ISO3166\ISO3166;

   #to get all countries
   $countries = (new ISO3166())->all();

   #to get a specific country details and currency for Philippines
   $country => (new ISO3166())->alpha3('PHL');

   #to get a specific country name for Philippines
   $country_name' => ((new ISO3166())->alpha3('PHL'))['name'];


Share:

Popular Posts

Recent Posts

Pages

Powered by Blogger.

About Me

My photo
For the past 10 years, I've been playing with codes using PHP, Java, Rails. I do this for a living and love new things to learn and the challenges that comes with it. Besides programming I love spending time with friends and family and can often be found together catching the latest movie or planning a trip to someplace I've never been before.