app->singleton('libphonenumber', function ($app) { return PhoneNumberUtil::getInstance(); }); $this->app->alias('libphonenumber', PhoneNumberUtil::class); $this->callAfterResolving('validator', function (Factory $validator) { $validator->extendDependent('phone', Validation\Phone::class . '@validate'); }); Rule::macro('phone', function () { return new Rules\Phone; }); } }