From 75285397795826286336c9888cb454cfd9a28435 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Sat, 11 Apr 2026 08:42:22 +1000 Subject: [PATCH] ci: add GitHub Actions workflow and update README --- .github/workflows/tests.yml | 34 ++++++++++++++++ README.md | 81 ++++++++++++++++++++++++++++++------- 2 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..bace6d6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php: ["8.4"] + + name: PHP ${{ matrix.php }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip + coverage: none + + - name: Install dependencies + run: composer install --prefer-dist --no-interaction --no-progress + + - name: Run tests + run: vendor/bin/pest diff --git a/README.md b/README.md index 4773fda..12d1908 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,84 @@ -Laravel Facebook Feed -============== +# Laravel Facebook Feed -A simple package to easily create an XML feed for Facebooks Shipping API to parse and retrieve your products on a frequent basis. +[![Latest Version on Packagist](https://img.shields.io/packagist/v/wearepixel/laravel-facebook-feed.svg)](https://packagist.org/packages/wearepixel/laravel-facebook-feed) +[![Tests](https://img.shields.io/github/actions/workflow/status/wearepixel/laravel-facebook-feed/tests.yml?label=tests)](https://github.com/wearepixel/laravel-facebook-feed/actions/workflows/tests.yml) +[![PHP Version](https://img.shields.io/packagist/php-v/wearepixel/laravel-facebook-feed.svg)](https://packagist.org/packages/wearepixel/laravel-facebook-feed) +[![Total Downloads](https://img.shields.io/packagist/dt/wearepixel/laravel-facebook-feed.svg)](https://packagist.org/packages/wearepixel/laravel-facebook-feed) +[![License](https://img.shields.io/packagist/l/wearepixel/laravel-facebook-feed.svg)](https://packagist.org/packages/wearepixel/laravel-facebook-feed) -We recommend adding this to an API controller and generating it on the fly each time so you can be sure your products are always up to date within your merchant center. +A simple package to easily create an XML feed for the Facebook Catalog API to parse and retrieve your products. + +We recommend adding this to an API controller and generating it on the fly so your feed is always up to date. + +## Requirements + +- PHP 8.4+ +- Laravel 10, 11, or 12 ## Installation -``` +```bash composer require wearepixel/laravel-facebook-feed ``` -## Example +## Usage + ```php use Wearepixel\LaravelFacebookFeed\LaravelFacebookFeed; $feed = LaravelFacebookFeed::init( - 'Product Feed', - 'App product Feed', - 'https://mystore.com' + title: 'My Store', + description: 'My store product feed', + link: 'https://mystore.com', ); $feed->addItem([ - 'id' => 'item_001', - 'title' => 'Blue Nikes', - 'link' => 'https://mystore.com/products/blue-nikes', - 'price' => 29.99, - 'image_link' => 'https://mystore.com/images/blue-nikes-001.jpg', + 'id' => 'item_001', + 'title' => 'Blue Nikes', + 'link' => 'https://mystore.com/products/blue-nikes', + 'price' => '29.99 AUD', + 'image_link' => 'https://mystore.com/images/blue-nikes-001.jpg', ]); return $feed->generate(); -``` \ No newline at end of file +``` + +### Required item fields + +| Field | Description | +| ------------ | ------------------------------------------------ | +| `id` | Unique product identifier | +| `title` | Product name | +| `link` | URL to the product page | +| `price` | Price including currency code (e.g. `29.99 AUD`) | +| `image_link` | URL to the main product image | + +Any additional fields supported by the [Facebook Product Feed Specification](https://www.facebook.com/business/help/120325381656392) can be passed alongside the required fields. + +### Methods + +**`LaravelFacebookFeed::init(string $title, string $description, string $link): static`** + +Creates a new feed instance with channel metadata. + +**`$feed->addItem(array $item): void`** + +Adds a product to the feed. Throws `MissingRequiredFieldException` if any required field is absent. + +**`$feed->toXml(): string`** + +Returns the feed as an XML string. + +**`$feed->generate(): Response`** + +Returns an HTTP response with the XML content and `application/rss+xml` content type. Suitable for returning directly from a controller. + +## Testing + +```bash +composer test +``` + +## License + +MIT