{"id":23162072,"url":"https://github.com/devnix/belfiore-code","last_synced_at":"2025-08-18T02:32:20.070Z","repository":{"id":56966869,"uuid":"239533235","full_name":"devnix/belfiore-code","owner":"devnix","description":"Serialized data of Italian Belfiore codes and foreign country codes","archived":false,"fork":false,"pushed_at":"2022-12-06T17:54:37.000Z","size":2517,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T22:56:11.749Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devnix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-10T14:36:04.000Z","updated_at":"2023-09-28T20:53:47.000Z","dependencies_parsed_at":"2023-01-23T11:30:30.672Z","dependency_job_id":null,"html_url":"https://github.com/devnix/belfiore-code","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/devnix/belfiore-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnix%2Fbelfiore-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnix%2Fbelfiore-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnix%2Fbelfiore-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnix%2Fbelfiore-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devnix","download_url":"https://codeload.github.com/devnix/belfiore-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnix%2Fbelfiore-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270933734,"owners_count":24670490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T23:24:01.573Z","updated_at":"2025-08-18T02:32:19.188Z","avatar_url":"https://github.com/devnix.png","language":"PHP","readme":"# devnix/belfiore-code\n\n[![Join the chat at https://gitter.im/DevNIX/belfiore-code](https://badges.gitter.im/DevNIX/belfiore-code.svg)](https://gitter.im/DevNIX/belfiore-code?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nOfficial Italian Belfiore code list (cadastral code) which represents a \n[comune](https://en.wikipedia.org/wiki/Comune).\n\n## Update\n\nTo update the database, you have to clone the project and install the\n`dev-dependencies`. Then, the console will be available to download and dump \nthe normalized datasets:\n\n```\ncomposer install\nbin/console update\n```\n\nand you are golden.\n\nAnyway, if you think that the crawled data is outdated, please \n[file an issue](https://github.com/devnix/belfiore-code/issues/new). I will \nupdate the new data ASAP.\n\n# Usage\n\n## Installation\n\n### PHP\n\n```\ncomposer require devnix/belfiore-code\n```\n\n## Serialized data\n\nYou can get the up to date serialized database of comunes and\nforeign regions in CSV, JSON, XML and YAML inside the `dist/` folder in any\nlanguage.\n\n## API\n\n### PHP\n\nThere is a `Devnix\\BelfioreCode\\Collection\\ComuneCollection` and a \n`Devnix\\BelfioreCode\\Collection\\RegionCollection` to get an `ArrayCollection`\nfilled with both databases. This enables you to directly iterate through them\nlike an array, or even perform queries of columns.\n\n#### Querying\n\nYou can fetch a comune by its `registry_code` (also know as  *cadastral code* or\n*belfiore code*).\n\n```php\n\u003c?php\n\nuse Devnix\\BelfioreCode\\Collection\\ComuneCollection;\nuse Doctrine\\Common\\Collections\\Criteria;\nuse Doctrine\\Common\\Collections\\Expr\\Comparison;\n\n$comunes = new ComuneCollection();\n\n$criteria = new Criteria();\n$criteria\n    -\u003ewhere(new Comparison('registry_code', Comparison::IS, 'A001'))\n;\n\nvar_dump($comunes-\u003ematching($criteria)));\n```\n\nThis would get you a new collection with the matching registry codes. As you can\nsee there is a comune called \"ABANO\" discontinued in 1924-11-13, and an active\ncomune called \"ABANO TERME\":\n```\nobject(Devnix\\BelfioreCode\\Collection\\ComuneCollection)#49 (1) {\n  [\"elements\":\"Doctrine\\Common\\Collections\\ArrayCollection\":private]=\u003e\n  array(2) {\n    [0]=\u003e\n    array(18) {\n      [\"id\"]=\u003e\n      string(5) \"12560\"\n      [\"institution_date\"]=\u003e\n      string(10) \"1866-11-19\"\n      [\"end_date\"]=\u003e\n      string(10) \"1924-11-13\"\n      [\"istat_id\"]=\u003e\n      string(6) \"028001\"\n      [\"registry_code\"]=\u003e\n      string(4) \"A001\"\n      [\"name_it\"]=\u003e\n      string(5) \"ABANO\"\n      [\"name_transliterated\"]=\u003e\n      string(5) \"ABANO\"\n      [\"alternative_name\"]=\u003e\n      string(0) \"\"\n      [\"alternative_name_transliterated\"]=\u003e\n      string(0) \"\"\n      [\"anpr_id\"]=\u003e\n      string(2) \"28\"\n      [\"istat_province_id\"]=\u003e\n      string(3) \"028\"\n      [\"istat_region_id\"]=\u003e\n      string(2) \"05\"\n      [\"istat_prefecture_id\"]=\u003e\n      string(0) \"\"\n      [\"status\"]=\u003e\n      string(12) \"discontinued\"\n      [\"provincial_code\"]=\u003e\n      string(2) \"PD\"\n      [\"source\"]=\u003e\n      string(0) \"\"\n      [\"last_update\"]=\u003e\n      string(10) \"2016-06-17\"\n      [\"istat_discontinued_code\"]=\u003e\n      string(6) \"028500\"\n    }\n    [1]=\u003e\n    array(18) {\n      [\"id\"]=\u003e\n      string(1) \"1\"\n      [\"institution_date\"]=\u003e\n      string(10) \"1924-11-14\"\n      [\"end_date\"]=\u003e\n      string(10) \"9999-12-31\"\n      [\"istat_id\"]=\u003e\n      string(6) \"028001\"\n      [\"registry_code\"]=\u003e\n      string(4) \"A001\"\n      [\"name_it\"]=\u003e\n      string(11) \"ABANO TERME\"\n      [\"name_transliterated\"]=\u003e\n      string(11) \"ABANO TERME\"\n      [\"alternative_name\"]=\u003e\n      string(0) \"\"\n      [\"alternative_name_transliterated\"]=\u003e\n      string(0) \"\"\n      [\"anpr_id\"]=\u003e\n      string(2) \"28\"\n      [\"istat_province_id\"]=\u003e\n      string(3) \"028\"\n      [\"istat_region_id\"]=\u003e\n      string(2) \"05\"\n      [\"istat_prefecture_id\"]=\u003e\n      string(2) \"PD\"\n      [\"status\"]=\u003e\n      string(6) \"active\"\n      [\"provincial_code\"]=\u003e\n      string(2) \"PD\"\n      [\"source\"]=\u003e\n      string(0) \"\"\n      [\"last_update\"]=\u003e\n      string(10) \"2016-06-17\"\n      [\"istat_discontinued_code\"]=\u003e\n      string(0) \"\"\n    }\n  }\n}\n```\n\nYou may want to find an active comune by his `registry_code`. To archieve this,\njust play with the\n[Doctrine Collections docs](https://www.doctrine-project.org/projects/doctrine-collections/en/1.6/index.html#introduction)\n\n```php\n\u003c?php\n\nuse Devnix\\BelfioreCode\\Collection\\ComuneCollection;\nuse Doctrine\\Common\\Collections\\Criteria;\nuse Doctrine\\Common\\Collections\\Expr\\Comparison;\n\n$comunes = new ComuneCollection();\n\n$criteria = new Criteria();\n$criteria\n    -\u003ewhere(new Comparison('registry_code', Comparison::IS, 'A001'))\n    -\u003eandWhere(new Comparison('status', Comparison::IS, 'active'))\n;\n\nvar_dump($comunes-\u003ematching($criteria)));\n```\n\nand it will grab for you your desired criteria:\n\n```\nobject(Devnix\\BelfioreCode\\Collection\\ComuneCollection)#55 (1) {\n  [\"elements\":\"Doctrine\\Common\\Collections\\ArrayCollection\":private]=\u003e\n  array(1) {\n    [1]=\u003e\n    array(18) {\n      [\"id\"]=\u003e\n      string(1) \"1\"\n      [\"institution_date\"]=\u003e\n      string(10) \"1924-11-14\"\n      [\"end_date\"]=\u003e\n      string(10) \"9999-12-31\"\n      [\"istat_id\"]=\u003e\n      string(6) \"028001\"\n      [\"registry_code\"]=\u003e\n      string(4) \"A001\"\n      [\"name_it\"]=\u003e\n      string(11) \"ABANO TERME\"\n      [\"name_transliterated\"]=\u003e\n      string(11) \"ABANO TERME\"\n      [\"alternative_name\"]=\u003e\n      string(0) \"\"\n      [\"alternative_name_transliterated\"]=\u003e\n      string(0) \"\"\n      [\"anpr_id\"]=\u003e\n      string(2) \"28\"\n      [\"istat_province_id\"]=\u003e\n      string(3) \"028\"\n      [\"istat_region_id\"]=\u003e\n      string(2) \"05\"\n      [\"istat_prefecture_id\"]=\u003e\n      string(2) \"PD\"\n      [\"status\"]=\u003e\n      string(6) \"active\"\n      [\"provincial_code\"]=\u003e\n      string(2) \"PD\"\n      [\"source\"]=\u003e\n      string(0) \"\"\n      [\"last_update\"]=\u003e\n      string(10) \"2016-06-17\"\n      [\"istat_discontinued_code\"]=\u003e\n      string(0) \"\"\n    }\n  }\n}\n```\n\n#### Ordering\n\nOrdering can be done too through Doctrine Collections. Please refer to their \n[docs](https://www.doctrine-project.org/projects/doctrine-collections/en/1.6/expressions.html#expressions)\nto see the available API:\n\n```php\n\u003c?php\n\nuse Devnix\\BelfioreCode\\Collection\\ComuneCollection;\nuse Doctrine\\Common\\Collections\\Criteria;\nuse Doctrine\\Common\\Collections\\Expr\\Comparison;\n\n$comunes = new ComuneCollection();\n\n$criteria = new Criteria();\n$criteria-\u003eorderBy(['last_update' =\u003e Criteria::ASC]);\n\nvar_dump($comunes-\u003ematching($criteria)));\n```\n\n\n# Roadmap\n\n- [ ] Write unit tests to verify that the data sources maintain the same format\n- [ ] Write unit tests to cover all classes\n- [ ] Write documentation of each column available in English\n- [ ] Investigate to run the update command automatically using Github Actions\nonce in a month\n\n# Contributing\n\nYou can contribute by forking the project and doing a pull request. Please, do \nall your work on the `develop` branch, or your PR will be rejected.\n\nAs I would love to get some feedback, specially from people more familiar than\nme with this kind of data, I will consider it as a WIP, and the API/column names\nmay change in the short term.\n\n# Attribution\n\n- Comunes List of Values: CC BY 4.0 Ministero dell'interno\n- Regions List of Values: CC BY 3.0 Istituto nazionale di statistica\n\nInspired by [Marketto/codice-fiscale-utils](https://github.com/Marketto/codice-fiscale-utils), \ndone to use in conjunction with [DavidePastore/codice-fiscale](https://github.com/DavidePastore/codice-fiscale)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevnix%2Fbelfiore-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevnix%2Fbelfiore-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevnix%2Fbelfiore-code/lists"}