1. Go to this page and download the library: Download carloeusebi/laravel-comuni library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
carloeusebi / laravel-comuni example snippets
use CarloEusebi\LaravelComuni\Facades\Comuni;
// Get all regions
$regions = Comuni::regioni();
// Get all provinces
$provinces = Comuni::province();
// Get all municipalities
$comuni = Comuni::comuni();
// Get municipalities by region
$comuni = Comuni::comuni(regione: 'Lazio');
// Get municipalities by province
$comuni = Comuni::comuni(provincia: 'Roma');
// Get municipalities with pagination
$comuni = Comuni::comuni(params: ['page' => 1, 'pagesize' => 10]);
// Filter municipalities by name
$comuni = Comuni::comuni(params: ['nome' => 'Roma']);
// Get only municipality names
$comuni = Comuni::comuni(params: ['onlyname' => true]);
// Filter regions by name
$regions = Comuni::regioni(['nome' => 'Lazio']);
return [
// currently the only provider is `comuni-ita`
'provider' => 'comuni-ita',
'cache' => [
// the prefix for the cache key
'prefix' => 'comuni-',
// the number of days the responses should be cached for
'ttl' => 60,
// the number of days after which the cache becomes stale
'stale' => 30,
],
];