germania-kg/categories

1.2.0 2023-01-09 14:36 UTC

This package is auto-updated.

Last update: 2024-09-09 18:18:36 UTC


README

此软件包是从旧代码中提炼出来的!
你最好不要在生产中使用它。

Packagist PHP version Tests

使用Composer安装

$ composer require germania-kg/categories

MySQL: 此软件包需要一个名为 categories 的MySQL表,您可以使用 sql/ 目录中的 germania_categories.sql 文件来安装。

用法

虽然 Categories 类是一个简单的存储,但 PdoCategories 从数据库读取所有下载。它们都实现了 PSR-11 ContainerInterface 以及其 container-interop 的前身,IteratorAggregate 和 SPL的 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();
?>

问题

另请参阅 完整问题列表。

开发

$ git clone https://github.com/GermaniaKG/Categories.git
$ cd Categories
$ composer install

单元测试

要么将 phpunit.xml.dist 复制到 phpunit.xml 并根据您的需求进行修改,要么保持原样。运行 PhpUnit 测试或 composer 脚本,如下所示

$ composer test
# or
$ vendor/bin/phpunit