PHP code example of tourze / doctrine-indexed-bundle

1. Go to this page and download the library: Download tourze/doctrine-indexed-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/ */

    

tourze / doctrine-indexed-bundle example snippets


return [
    // ...
    Tourze\DoctrineIndexedBundle\DoctrineIndexedBundle::class => ['all' => true],
];

use Tourze\DoctrineIndexedBundle\Attribute\IndexColumn;
use Tourze\DoctrineIndexedBundle\Attribute\FulltextColumn;
use Tourze\DoctrineIndexedBundle\Attribute\UniqueColumn;

class YourEntity
{
    #[ORM\Column]
    #[IndexColumn] // Regular index
    private string $name;

    #[ORM\Column(type: 'text')]
    #[FulltextColumn] // Fulltext index
    private string $description;

    #[ORM\Column]
    #[UniqueColumn] // Unique index
    private string $email;
}

#[IndexColumn(name: 'custom_index_name')]
private string $field;

#[IndexColumn(name: 'search_idx')]
private string $searchable;

#[FulltextColumn(name: 'content_fulltext')]
private string $content;

#[UniqueColumn(name: 'email_unique')]
private string $email;

class Product
{
    #[ORM\Column]
    #[IndexColumn] // For searching
    #[UniqueColumn] // For uniqueness
    private string $sku;

    #[ORM\Column(type: 'text')]
    #[FulltextColumn] // For full-text search
    #[IndexColumn] // For regular search too
    private string $description;
}