Download the PHP package paxxion/craft-country-load without Composer

On this page you can find all versions of the php package paxxion/craft-country-load. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-country-load

country-load

A friendly country/region selector for Craft CMS 5

What it is

Having the country/area dropdowns is one of those things that you need in just about every site. Natively, Craft has its own database but only few countries have their regions. So, we've wrapped the Symfony Intl component and L91/ISO 3166-2 library in a simple plugin, with its own Alpine-powered widget.

BONUS: Since we use this plugin in our own websites, and we are Italian, we also included all of Italy's province.

Disclaimer

This plugin uses open-source PHP libraries to list countries and regions. The data comes from public sources we don’t control, so it might not always be perfect or up to date. Use it “as is” — we can’t take responsibility for any errors or issues that come from the data.

How to use

craft.countryLoad.countries(lang)

This gives you an array of countries and country codes. By default it will use currentSite.language but you can pass an optional parameter in order to localize country names.

The result array is always split into base and promoted countries. This makes it much easier to handle on the frontend but if you don’t like it you can just merge the two arrays.

Important: base results are in alphabetical order, promoted results respect the order in which they’ve entered.

Promoted but “unallowed” countries will be ignored.

craft.countryLoad.regions(countryCode)

This gives you an array of regions for the provided countryCode (case-insensitive).

craft.countryLoad.italyProvinces(region)

Returns all the provinces for the specified Italian region. If you don't pass a region, you will get the complete provinces array. Note that each province has two keys, name and code since it's quite common to need both:

Plugin settings

On top of that Country Load gives you some nice extras:

Limit which countries are displayed

Do you only sell to EU? You don’t need to show 200+ countries. Select the countries you want to show in the plugin settings.

Push specific countries to the top

Make your primary markets easier to find.

Ready-made widget

We’ve included a simple country/area widget, powered by Alpine.js:

craft.countryLoad.dropdown(options)

widget options

CountryLoad is BYOS (bring your own style). At the very least, labels need to have a class with display: block otherwise they'll look quite wrong.

Pretty straightforward. Please note that if you set required.country to false, required.region will be ignored.

Labels for fields and empty states.

Fields names are also customizable so it's easier to integrate in your own forms.

You can optionally enable a third dropdown to let users choose their Italian province.

Specify a language for country names. If you don't, currentSite.language will be used.

Example

A simple Tailwind-based dropdown example with common settings. Of course, you can just use it like so:

FAQ

Region X of country Z is not listed!

Unfortunately, we cannot help you with that. Please refer to the included libraries mentioned above to submit your request.

Why Italian municipalities (comuni) are not included?

It's quite uncommon to need them and we wanted to stay practical. Also, we're still looking for a reliable (and up to date) source of information.

I don’t like your widget!

No problem, you have all you need to build one yourself.

Why is Palestine included?

Why not?


All versions of craft-country-load with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
craftcms/cms Version ^5.8.0
l91/iso-3166-2 Version ^1.0
symfony/intl Version ^7.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package paxxion/craft-country-load contains the following files

Loading the files please wait ...