The internal dependency giggsey/libphonenumber-for-php
is now substituted by giggsey/libphonenumber-for-php-lite
.
libphonenumber-for-php-lite
is a lightweight drop-in replacement for libphonenumber-for-php
, significantly reducing the package size being pulled in. libphonenumber-for-php-lite
excludes geolocation, carrier information and short number info.
This is a non-breaking change for functionality provided by Laravel-Phone
.
However, if you have defined a macro, please review your code and if needed require giggsey/libphonenumber-for-php
as an explicit dependency in your project.
The package now minimally requires PHP 8.0 and Laravel 9.0. It also supports Laravel 10. All documented behavior is preserved. There are just some minor syntactical changes that might need your attention.
Estimated time to upgrade: 0 to 5 minutes
- The
Phone
rule is now available to be referenced as a rule object (Propaganistas\LaravelPhone\Rules\Phone
):'phonefield' => (new Phone)->mobile()->country('BE')
- The
detect()
method of the Rule macro has been renamed tointernational()
to better describe its behavior.'phonefield' => Rule::phone()->detect() // becomes 'phonefield' => Rule::phone()->international()
- The
AUTO
parameter has been renamed toINTERNATIONAL
to better describe its behavior.'phonefield' => 'phone:AUTO' // becomes 'phonefield' => 'phone:INTERNATIONAL'
- The
make()
method has been removed as it was redundant. Use thephone()
helper or simply construct a new object.PhoneNumber::make($number, $country) // becomes phone($number, $country) // 1-to-1 replacement ; chainable with subsequent methods // or new PhoneNumber($number, $country) // wrap in additional parentheses to chain with subsequent methods
- the
ofCountry()
method has been removed. Specification of possible countries is now only possible while constructing the object.$object = new PhoneNumber($number); $object->ofCountry($country); // becomes $object = new PhoneNumber($number, $country); // or phone($number, $country)
- The undocumented public method
numberLooksInternational()
has been removed. There is no alternative.
- Similar to the other cast,
RawPhoneNumberCast
will now also throw an exception when it gets invoked with an invalid phone object (i.e. while accessing the casted attribute). Make sure to validate phone numbers before persisting them and provide the appropriate country code to the cast.