PHP code example of jonaskohl / php-search

1. Go to this page and download the library: Download jonaskohl/php-search 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/ */

    

jonaskohl / php-search example snippets


use VFou\Search\Engine;

$engine = new Engine();

$doc = [
    "id" => 1,
    "type" => "example-post",
    "title" => "this is my first blog post !",
    "content" => "I am very happy to post this first post in my blog !",
    "categories" => [
        "party",
        "misc."
    ],
    "date" => "2018/01/01",
    "comments" => [
        [
            "author" => "vincent",
            "date" => "2018/01/01",
            "message" => "Hello world!"
        ],
        [
            "author" => "someone",
            "date" => "2018/01/02",
            "message" => "Welcome !"
        ]
    ]
];
$engine->update($doc);
$doc = [
    "id" => 2,
    "type" => "example-post",
    "title" => "This is the second blog post",
    "content" => "a second one for fun",
    "date" => "2018/01/05",
    "categories" => [
        "misc."
    ],
    "comments" => [
        [
            "author" => "someone",
            "date" => "2018/01/05",
            "message" => "Another one ?!"
        ]
    ]
];
$engine->update($doc);

$response = $engine->search('second post');
var_dump($response);

$response = $engine->search('post');
var_dump($response);



use VFou\Search\AdminPanel;

// include the composer autoload file, modify the path if needed
nauthorized');

// instantiate the panel and then run it
$admin = new AdminPanel();
echo $admin->run();