smart-dato / non-solo-cap
A set of tools to make working with https://www.nonsolocap.it/ easier in Laravel
Requires
- php: ^8.2|^8.5
- guzzlehttp/guzzle: ^7.5
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-23 14:34:13 UTC
README
A small Laravel helper that checks whether an Italian postal code (CAP) exists, using NonSoloCap. All data belongs to NonSoloCap, which offers far more than this package uses and has one of the best databases of Italian postal codes.
Requirements
- PHP 8.2+
- Laravel 8 – 13
Installation
composer require smart-dato/non-solo-cap
The service provider and the NonSoloCap facade alias are registered automatically.
Usage
use SmartDato\NonSoloCap\Services\NonSoloCap; NonSoloCap::validZipcode('39021'); // true NonSoloCap::validZipcode('99999'); // false NonSoloCap::generateUrl('39021', 'Laces'); // https://www.nonsolocap.it/?k=39021&c=Laces
validZipcode() queries nonsolocap.it and returns false when the site reports no results. It makes a live HTTP request each time and throws a Guzzle exception if the site cannot be reached, so cache the result if you check the same codes often.
generateUrl() only builds a link to the site's search page for a postal code and/or place name; it makes no request.
Testing
composer test
The validation test calls nonsolocap.it, so it needs network access.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.