germania-kg / google-structured-data
用于设置FAQ结构化数据的类
1.0.2
2021-07-07 07:27 UTC
Requires
- php: ^7.0|^8.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-07 14:37:20 UTC
README
使用Composer安装
$ composer require germania-kg/google-structured-data
用法
<?php use Germania\GoogleStructuredData\GoogleFaqQuestion; use Germania\GoogleStructuredData\GoogleFaqAnswer; use Germania\GoogleStructuredData\GoogleFaqCollection; $answer = GoogleFaqAnswer::create("This is the answer."); $answer = $answer->setText("No, another answer."); // Answer is optional $question = GoogleFaqQuestion::create("So, what is the answer?", $answer); $question = GoogleFaqQuestion::create("So, what is the answer?"); $question->setAcceptedAnswer($answer) $faq = GoogleFaqCollection::createFromArray([ $question, ... ]);
单元测试
可以复制 phpunit.xml.dist
到 phpunit.xml
并根据您的需求进行修改,或者保持原样。运行 PhpUnit 测试或Composer脚本如下
$ composer test # or $ vendor/bin/phpunit