I got it! my problem was that I already have installed x-pack plugin in my elasticsearch instance, so the ssl certificates are already inside of elasticsearch.yml file. so the only code that i needed in PHP was:
$hosts = ['https://www.xxxxxxxx.com:6767'];
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
->setHosts($hosts)
->build(); // Build the client object
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.