1

I am using the php implmentation of libphonenumber from

giggsey/libphonenumber-for-php

I need it to just do a basic sense and validity check on a phone number entered by a users.

I have taken the whole src/libphonenumber directory and its sub directories and copied it into my project. I do not use Composer and, as this is only one element of my project, am hoping not to have to climb that particular learning curve just now. I put the following simple autoloader at the start of the script.

namespace libphonenumber;

spl_autoload_register('libphonenumber\myAutoloader');

function myAutoloader($className)
{
$path = 'libphonenumber/';
$parts=explode('\\',$className,2);
$filename=str_replace('\\','/',$parts[1]);

include $path.$filename.'.php';
}

The auto loader works fine except for when it comes to include the file geocoding/Locale.php which includes a single class 'Locale' as follows;

class Locale extends \Locale

The error I get is

PHP Fatal error:  Class 'Locale' not found in /var/www/luthor/php/libphonenumber/geocoding/Locale.php on line 6

I am pretty new to namespaces and oo in php. I understand that Locale is a php class. My question is Why is it not found

anthonyc
  • 187
  • 3
  • 13
  • I see you have already solved this, but thought I best comment: The package requires the php 'intl' extension, which is listed in the requirements when installed via Composer. I will make sure that it is listed clearly in the README for those not using Composer. – giggsey Aug 21 '14 at 15:25

1 Answers1

0

Found the answer. The use of Locale requires the international extension for php to be installed see the following question

Fatal error: Class 'Locale' not found with ZF2 beta5 skeleton application

Community
  • 1
  • 1
anthonyc
  • 187
  • 3
  • 13