PHP code example of germania-kg / categories

1. Go to this page and download the library: Download germania-kg/categories 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/ */

    

germania-kg / categories example snippets



use Germania\Categories\Categories;
use Germania\Categories\PdoCategories;
use Germania\Categories\Category;

//
// 1. Simple usage:
//
$categories = new Categories( );

$cat = new Category;
$cat->setSlug( 'cars' );
$categories->push( $cat );


//
// 2. Or, get all from PDO datebase:
//
$categories = new PdoCategories( $pdo );


//
// Check on ID and retrieve
//
$check = $categories->has( 42 );
$my_cat = $categories->get( 42 );

echo $my_cat->getSlug();