1. Go to this page and download the library: Download worksome/verify-by-phone library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
worksome / verify-by-phone example snippets
public function sendVerificationCode(Request $request, PhoneVerificationService $verificationService)
{
// Send a verification code to the given number
$verificationService->send(new PhoneNumber($request->input('phone')));
return redirect(route('home'))->with('message', 'Verification code sent!');
}
public function verifyCode(Request $request, PhoneVerificationService $verificationService)
{
// Verify the verification code for the given phone number
$valid = $verificationService->verify(
new PhoneNumber($request->input('phone')),
$request->input('code')
);
if ($valid) {
// Mark your user as valid
}
}
it('tests something to do with SMS verification', function () {
$service = new FakeVerificationService();
$this->swap(PhoneVerificationService::class, $service);
// Customise what happens when calling `send`
$service->sendUsing(fn () => throw new Exception('Something went wrong'));
// Customise what happens when calling `verify`
$service->verifyUsing(fn () => throw new Exception('Something went wrong'));
// Throw a VerificationCodeExpiredException
$service->actAsThoughTheVerificationCodeExpired();
// Assert that a verification was "sent" on the given number
$service->assertSentVerification(new PhoneNumber('+441174960123'));
});
xml
<env name='VERIFY_BY_PHONE_DRIVER' value='null'/>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.