germania-kg / categories
1.2.0
2023-01-09 14:36 UTC
Requires
- php: ^7.4|^8.0
- container-interop/container-interop: ^1.1
- psr/container: ^1.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpspec/prophecy: ^1.16
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.0
README
This package was destilled from legacy code!
You better do not want it to use this in production.
Installation with Composer
$ composer require germania-kg/categories
MySQL: This package requires a MySQL tables categories which you can install using germania_categories.sql
in sql/
directory.
Usage
While the Categories class is a simple storage, PdoCategories reads all downloads from the database. They both implement the PSR-11 ContainerInterface as well as its container-interop antecessor, IteratorAggregate and SPL's Countable.
<?php 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(); ?>
Issues
- Since PSR 11 is now standard, container-interop should be retired. Discuss at issue #1.
Also see full issues list.
Development
$ git clone https://github.com/GermaniaKG/Categories.git
$ cd Categories
$ composer install
Unit tests
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test # or $ vendor/bin/phpunit