germania-kg / google-structured-data
Classes for setting up FAQ structured data
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-11-07 15:00:50 UTC
README
Installation with Composer
$ composer require germania-kg/google-structured-data
Usage
<?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, ... ]);
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