PHP code example of hopeter1018 / doctrine-full-text-search-bundle

1. Go to this page and download the library: Download hopeter1018/doctrine-full-text-search-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/ */

    

hopeter1018 / doctrine-full-text-search-bundle example snippets


return [
  ...,
  HoPeter1018\DoctrineFullTextSearchBundle\HoPeter1018DoctrineFullTextSearchBundle::class => ['all' => true],
];

$bundles = [
  ...,
  new HoPeter1018\DoctrineFullTextSearchBundle\HoPeter1018DoctrineFullTextSearchBundle(),
];

namespace App\Entity;

use HoPeter1018\DoctrineFullTextSearchBundle\Annotation as Fts;
use HoPeter1018\DoctrineFullTextSearchBundle\Formatter\DateTimeFormatter;

/**
 * @Fts\Entity(
 *     columns={
 *         "__property_name_1__": @Fts\Column,
 *         "__property_name_2__": @Fts\Column(formatter=DateTimeFormatter::class),
 *     },
 *     columnGroups={
 *         "__group_name_1__": @Fts\ColumnGroup(columns={
 *             "__property_name_1__": @Fts\Column,
 *             "__property_name_2__": @Fts\Column,
 *         })
 *     }
 * )
 */
class TheEntity
{
    /**
     * @Fts\Column
     * @ORM\Column(type="string", length=255)
     */
    private $propertyName1;

    /**
     * @Fts\Column
     */
    public function methodName1()
    {
        return 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
    }
}

use HoPeter1018\DoctrineFullTextSearchBundle\Entity\FullTextSearchIndex;

$fullTextSearchIndexRepo = $em->getRepository(FullTextSearchIndex::class);

$ids = $fullTextSearchIndexRepo->search('~~ The search keywords ~~', TheEntity::class, ['__name-property/group/method__']);

$repo = $em->getRepository(TheEntity::class);
$list = $repo->findBy(['id' => $ids]);