PHP code example of fpn / doctrine-extensions-taggable

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

    

fpn / doctrine-extensions-taggable example snippets




    // somewhere crate or already have the entity manager
    // $em = EntityManager::create($connection, $config);

    $tagRepo = $em->getRepository('DoctrineExtensions\\Taggable\\Entity\\Tag');

    // find all article ids matching a particular query
    $ids = $tagRepo->getResourceIdsForTag('article_type', 'footag');

    // get the tags and count for all articles
    $tags = $tagRepo->getTagsWithCountArray('article_type');
    foreach ($tags as $name => $count) {
        echo sprintf('The tag "%s" matches "%s" articles', $name, $count);
    }