1. Go to this page and download the library: Download dco-ai/php-jina 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/ */
dco-ai / php-jina example snippets
use DcoAi\PhpJina\JinaClient;
$config = [
"url" => "localhost", // The URL or endpoint of your Jina installation
"port" => "1234", // The port used for your Jina Installation
"endpoints" => [ // These are the active endpoints in your Jina application with the corresponding method
"/status" => "GET",
"/post" => "POST",
"/index" => "POST",
"/search" => "POST",
"/delete" => "DELETE",
"/update" => "PUT",
"/" => "GET"
]
];
$jina = new JinaClient($config);
// this creates a Document that you can add data to the structure
$d = $jina->document();
// This creates a DocumentArray that Documents can be added to
$da = $jina->documentArray();
// This adds Documents to a DocumentArray
$jina->addDocument($da, $d);
// This sends the DocumentArray to your JinaClient application and returns the result.
$jina->submit("/index",$da);
use DcoAi\PhpJina\JinaClient;
// set the config and create a new instance of the JinaClient
$config = [
"url" => "localhost",
"port" => "1234",
"endpoints" => [
"/status" => "GET",
"/post" => "POST",
"/index" => "POST",
"/search" => "POST",
"/delete" => "DELETE",
"/update" => "PUT",
"/" => "GET",
]
];
$jina = new JinaClient($config);
// create a new instance of the filter class
$filterBuilder = $jina->useFilterFormatter();
// Lets make an empty DocumentArray
$da = $jina->documentArray();
// And add the filter to the parameters
$da->parameters->filter = $filterBuilder->createFilter();
// print ths document and see what we got
print_r(json_encode($da, JSON_PRETTY_PRINT));
use DcoAi\PhpJina\JinaClient;
// set the config and create a new instance of the JinaClient
$config = [
"url" => "localhost",
"port" => "1234",
"endpoints" => [
"/status" => "GET",
"/post" => "POST",
"/index" => "POST",
"/search" => "POST",
"/delete" => "DELETE",
"/update" => "PUT",
"/" => "GET",
],
"dataStore" => [
"type" => "annlite",
]
];
$jina = new JinaClient($config);
use DcoAi\PhpJina\JinaClient;
// set the config and create a new instance of the JinaClient
$config = [
"url" => "localhost",
"port" => "1234",
"endpoints" => [
"/status" => "GET",
"/post" => "POST",
"/index" => "POST",
"/search" => "POST",
"/delete" => "DELETE",
"/update" => "PUT",
"/" => "GET",
],
"dataStore" => [
"type" => "weaviate",
"url" => "localhost",
"port" => "8080",
]
];
$jina = new JinaClient($config);
// setting the third parameter to false will not remove any empty values from the response
$jina->submit("/index", $da, false);