tombroucke/otomaties-google-reviews-widget

Display a Google reviews widget

Maintainers

Package info

github.com/tombroucke/otomaties-google-reviews-widget

Type:package

pkg:composer/tombroucke/otomaties-google-reviews-widget

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-03-16 21:47 UTC

This package is auto-updated.

Last update: 2026-03-16 21:48:03 UTC


README

A Laravel/Acorn package that displays Google My Business reviews as a beautiful widget. The widget shows the Google logo, star ratings (including half stars), average rating, and total number of reviews.

Features

  • Displays Google Business reviews with logo, stars, rating, and count
  • Supports full and half star ratings
  • Caches review data (default: 24 hours)
  • Daily fetch command for automated updates
  • Fully configurable via .env and config file
  • Responsive design with mobile support

Installation

Install the package via Composer:

composer require otomaties/otomaties-google-reviews-widget

Publish the configuration file:

wp acorn vendor:publish --tag="otomaties-google-reviews-widget-config"

Publish the CSS assets (optional):

wp acorn vendor:publish --tag="otomaties-google-reviews-widget-assets"

Configuration

1. Get Your Google Place ID

Find your business's Place ID:

  1. Go to the Place ID Finder
  2. Search for your business
  3. Copy the Place ID (looks like: ChIJN1t_tDeuEmsRUsoyG83frY4)

2. Create a Google API Key

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Go to APIs & Services > Library
  4. Search for and enable "Places API"
  5. Go to APIs & Services > Credentials
  6. Click Create Credentials > API Key
  7. Copy the API key
  8. (Recommended) Click Restrict Key and limit it to "Places API" only

3. Configuration

Add your Place ID to the config file:

Edit config/otomaties-google-reviews-widget.php (publish it first if needed):

'place_id' => 'ChIJN1t_tDeuEmsRUsoyG83frY4',

Add your API key to .env:

# Your Google API Server Key (from step 2)
GOOGLE_API_SERVER_KEY=AIzaSyD1234567890abcdefghijklmnopqrstuv

# Optional: Cache duration in seconds (default: 86400 = 24 hours)
GOOGLE_REVIEWS_CACHE_DURATION=86400

3. Configuration File

The config file (config/otomaties-google-reviews-widget.php) allows you to customize display settings:

'display' => [
    'show_logo' => true,   // Show Google logo
    'show_stars' => true,  // Show star ratings
    'show_rating' => true, // Show average rating number
    'show_count' => true,  // Show review count
],

Usage

Display the Widget

Using Shortcode:

[google_reviews_widget]

Using Blade:

@include('GoogleReviewsWidget::widget')

Don't forget to include the CSS file in your theme:

<link
  rel="stylesheet"
  href="{{ asset('vendor/otomaties-google-reviews-widget/google-reviews-widget.css') }}"
/>

Fetch Reviews

Manually fetch the latest reviews:

wp acorn google-reviews:fetch

Schedule Daily Updates

Add to your app/Console/Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->command('google-reviews:fetch')->daily();
}

Or set up a cron job:

0 2 * * * cd /path/to/your/site && wp acorn google-reviews:fetch

Programmatic Usage

You can also use the service directly in your code:

use Otomaties\GoogleReviewsWidget\Services\GoogleReviewsService;

$service = new GoogleReviewsService();

// Get cached reviews
$reviews = $service->getReviews();

// Fetch fresh reviews
$reviews = $service->fetchReviews();

// Get star rating breakdown
$stars = $service->getStarRating(4.5);
// Returns: ['full' => 4, 'half' => 1, 'empty' => 0]

Community

Keep track of development and community news.