PHP code example of nowo-tech / search-kit-bundle

1. Go to this page and download the library: Download nowo-tech/search-kit-bundle 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/ */

    

nowo-tech / search-kit-bundle example snippets


// config/bundles.php
return [
    Nowo\SearchKitBundle\NowoSearchKitBundle::class => ['all' => true],
];

use Nowo\SearchKitBundle\Contract\SearchProviderInterface;
use Nowo\SearchKitBundle\Model\SearchGroup;
use Nowo\SearchKitBundle\Model\SearchItem;
use Nowo\SearchKitBundle\Model\SearchQuery;
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;

#[AsTaggedItem(priority: 50)]
final readonly class ProjectSearchProvider implements SearchProviderInterface
{
    public function __construct(private ProjectRepository $projects)
    {
    }

    public function search(SearchQuery $query): ?SearchGroup
    {
        $rows = $this->projects->searchVisibleTo($query->user, $query->text, $query->limit);

        return new SearchGroup('projects', 'Projects', array_map(
            static fn (Project $p): SearchItem => new SearchItem($p->getName(), '/projects/' . $p->getId(), $p->getSlug(), 'tabler:folder'),
            $rows,
        ));
    }
}