- How do I install slvler/phone-validation in a Laravel app?
- Install it with composer require slvler/phone-validation, then publish the package config using php artisan vendor:publish. Add your AbstractAPI key through an environment variable backed by your secret manager and confirm the config still works with config:cache. Integration is intentionally light, roughly an afternoon including tests, so the real effort goes into caching, fallback, and an abstraction boundary rather than the install itself.
- Does slvler/phone-validation validate phone numbers locally?
- No. It is a thin Laravel-flavored HTTP client for AbstractAPI's phone_validation endpoint, so every check is a network round trip and a billable API call. The package returns the vendor's JSON payload, including validity, E.164 format, country, carrier, and line type. If you need free local format checks, pair it with a library such as giggsey/libphonenumber-for-php and only call the API for enrichment.
- Which Laravel and PHP versions does slvler/phone-validation support?
- The supported Laravel and PHP bounds are not clearly documented, so inspect composer.json before adopting. Verify it runs on Laravel 10 or 11 and PHP 8.2 or newer in a throwaway branch. If it caps at an older framework or PHP version, it will block your upgrade path and you should plan to fork it.
- Can I use slvler/phone-validation as a validation rule in Laravel form requests?
- The package markets a simple validation rule for checking number format and country code, but underneath it performs a synchronous third-party API call. That is fine for low-volume admin forms, but avoid dropping it into a default request rule on hot paths. Wrap it in your own rule with caching, timeout handling, and a local pre-check so an API failure never silently reads as an invalid number.
- Is slvler/phone-validation safe for high-traffic registration or checkout flows?
- It is a poor fit as a gatekeeper for latency-sensitive paths because it adds a synchronous third-party dependency to every request. Quota exhaustion or a non-200 response can surface as null or an empty result that callers misread as an invalid number. Validate format locally first, then enrich only where a product requirement actually needs carrier or line-type data.
- How much does slvler/phone-validation cost to run?
- The package itself is free, but each validation is a billable AbstractAPI call, and pricing, rate limits, and terms are the vendor's, not the package's. Add a local format and prefix pre-check plus a Redis cache keyed on a salted hash of the E.164 number with a 30 to 90 day TTL. That combination typically cuts billable calls by 40 to 70 percent.
- How does slvler/phone-validation handle timeouts and API errors?
- Return values are untyped arrays or JSON, so a non-200, quota-exhausted, or timed-out response may come back as null or an empty result rather than an exception. Check whether HTTP timeouts, retries, and connection pooling are configurable at all; if they are not, you inherit Guzzle defaults. Wrap the client and raise explicit exception types for timeout, quota, and malformed response so failures are never confused with an invalid number.
- Should I call slvler/phone-validation directly from controllers and models?
- The recommended pattern is to wrap it, not call it directly. Define an internal PhoneValidator contract that returns a typed DTO with isValid, e164, country, carrier, lineType, and source, then bind the package client behind that contract in a service provider. This keeps Slvler namespaces out of your domain code and turns a vendor swap into a config change.
- Is slvler/phone-validation actively maintained?
- Treat it as unmaintained by default: it has around 28 stars, a single maintainer, no visible CI or security policy, and no meaningful release cadence. The package is only roughly 100 to 200 lines of glue over an HTTP call, so assume you own the code after adoption and are prepared to fork it. The bigger lock-in is the AbstractAPI contract, not the package.
- What are the alternatives to slvler/phone-validation?
- For pure format and country checks, giggsey/libphonenumber-for-php handles normalization to E.164 locally at no cost. If you only need this one endpoint, a direct Http::withToken call to AbstractAPI replaces the package in a few lines. For polyglot estates with Node or Python services, stand up an internal validation endpoint instead of adopting a PHP-only wrapper.