We are updating our codebase to use the namespace functionality provided in PHP-5.3+
Previously, our files all lived happily on the webserver in /htdocs/php but now we are separating our scripts, and putting our PHP libraries in /htdocs/php/lib/
In /htdocs/php/lib/ we have a file called Jira.php which we have given a namespace to:
<?php
# Define a namespace for this library
namespace Jira;
function create_client($jira_url, $options)
{
global $client;
try
{
$client = new SoapClient($jira_url, $options);
}
catch (Exception $error)
{
echo $error -> getMessage() . "<br/><p style='color:red'> Could not connect to Jira </p>";
}
}
?>
However, when we try and call this function from a script in /htdocs/php, we are getting the class not found error:
PHP Fatal error: Class 'Jira\SoapClient' not found
This is failing when we try creating the SoapClient object.
I have verified that I have the php-soap package installed in /usr/share/php/SOAP/ and php_info(); is showing that it is enabled etc.
So presumably this is a problem with the namespace convention. How do we include that class without it throwing an error?
Regards, ns