I have a PHP file which is connected to elasticsearch, where I am indexing my documents.
My elasticIndex.php file:
**class elasticIndex{
function elasticFun(){
require 'vendor/autoload.php';
$client = new Elasticsearch\Client();
$feed = 'http://blaasd.zasdp.tv/Xml';
$xml = simplexml_load_file($feed);
foreach ($xml-> .......
......}**
Now the problem is I am working on Symfony framework, where in the beginning of a PHP file you have to address the namespace, like:
**namespace MyBundle\Controller**
That is why I am unable to use the following two lines in my controller class:
require 'vendor/autoload.php';
$client = new Elasticsearch\Client();
So I have created a new PHP file (elasticIndex.php)and writen code for elasticsearch indexing. So how can I call my function elasticFun()
from my elasticIndex class to my controller class. for not using the namespace in the elasticIndex class, it is not address anywhere in my Symfony project.
So how can I call my elasticFun()
function which is not addressed to anywhere from my controller class?
i have also try to use the global namespace like ---
**use MyBundle\VideoProviderClient\elasticIndex as _val;
class ExternalClientControlController extends Controller {
public function ExternalClientControlAction() {
$_val = new \elasticIndex();
return new Response($_val);
}**
it gives an error -- Attempted to load class "elasticIndex" from the global namespace.Did you forget a "use" statement?
Can anyone kindly help me with this. Thanks a lot in advanced ...