Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

equipc's avatar
Level 17

Country list

What do you use to generate a country list dropdown in a form ?

Is there any interesting package or helpers that I can use ? Does I have to set the list manually ?

0 likes
12 replies
equipc's avatar
Level 17

@bashy I don't think a DB table is needed for this ... I would prefer to create a class with a PHP array containing all the value ... Something like we have for language or config but I don't know how to do it.

1 like
bashy's avatar

@equipc Well of course I don't know what's best but I'm just giving you options :)

1 like
icon's avatar

Dear all!

I am working with "Core PHP" since 15years, but I am new to Laravel: I have started my first project this morning ;-)

I am using the built in Auth package of Laravel which is working very well. https://github.com/webpatser/laravel-countries is the first package which I tried to install "manually".

I followed all the instructions from the GitHub description as good as I can, but there are several problems: a) there is no app/config/app.php (in Laravel 5.4.15), so I am using config/app.php instead which seems to be correct b) 'providers' => ['Webpatser\Countries\CountriesServiceProvider' looks different in my version, so I have changed to: Webpatser\Countries\CountriesServiceProvider::class, --> is this correct?? c) 'aliases' => ['Countries' => 'Webpatser\Countries\CountriesFacade', looks different in my version, so I changed it: 'Countries' => Webpatser\Countries\CountriesFacade::class, d) I tried to execute $ php artisan countries:migration but it is not working. Then I have created $ php artisan make:command countries:migration which could be executed correctly but did not solve my problem (sorry for being so naiv...)

I am checking in the internet, but I cannot find a solution for my problem. Any help/suggestion is welcome very much!

Thanks a lot in advance, iCon!

spekkionu's avatar

You might be better off using the list in the symfony/intl package as the list is likely kept up to date a bit better than other options.

Also the package linked to previously uses the database to store the country data which I don't really think is the best place for it.

5 likes

Please or to participate in this conversation.