PHP code example of iraq-laravel / phone
1. Go to this page and download the library: Download iraq-laravel/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/ */
iraq-laravel / phone example snippets
use IraqLaravel\Phone\Facades\IraqiPhone;
$phone = IraqiPhone::parse('0780 123 4567');
$phone->local; // 07801234567
$phone->e164; // +9647801234567
$phone->formatted(); // 0780 123 4567
$phone->prefix(); // 0780
$phone->subscriberNumber(); // 1234567
$phone->operator; // Operator::Zain
$phone->operator->name(); // Zain Iraq
$phone->operator->label(); // زين العراق
$phone->isMobile; // true
use IraqLaravel\Phone\Rules\IraqiPhoneNumber;
use IraqLaravel\Phone\Enums\Operator;
// Any valid Iraqi number
'phone' => ['fic operators
'phone' => ['
'phone' => ''
use IraqLaravel\Phone\Rules\IraqiPhoneNumber;
class RegisterRequest extends FormRequest
{
public function rules(): array
{
return [
'name' => ['
$phone = IraqiPhone::parse('060123456'); // Mosul landline
$phone->isMobile; // false
$phone->areaName; // "Mosul / Nineveh"
$phone->areaNameAr; // "الموصل / نينوى"
$phone->areaNameKu; // 'مووسڵ / نەینەوا' (Kurdish Sorani)
$phone->operator; // Operator::Unknown
$phone->e164; // +96460123456
IraqiPhone::parse('07801234567')->toArray();
// [
// 'raw' => '07801234567',
// 'local' => '07801234567',
// 'e164' => '+9647801234567',
// 'formatted' => '0780 123 4567',
// 'prefix' => '0780',
// 'subscriber' => '1234567',
// 'operator' => 'zain',
// 'operator_name' => 'Zain Iraq',
// 'operator_label' => 'زين العراق',
// 'operator_label_localized' => 'Zain Iraq',
// 'is_mobile' => true,
// 'area_name' => null,
// 'area_name_ar' => null,
// 'area_name_ku' => null,
// ]
use IraqLaravel\Phone\IraqiPhone;
$service = new IraqiPhone();
$phone = $service->parse('07801234567');
use IraqLaravel\Phone\Exceptions\InvalidIraqiPhoneNumberException;
if (IraqiPhone::isValid($input)) {
$phone = IraqiPhone::parse($input);
}
// Or catch explicitly:
try {
$phone = IraqiPhone::parse($input);
} catch (InvalidIraqiPhoneNumberException $e) {
// handle error
}
bash
php artisan vendor:publish --tag=iraqi-phone
bash
php artisan vendor:publish --tag=iraqi-phone-config