tombroucke / otomaties-google-reviews-widget
Display a Google reviews widget
Package info
github.com/tombroucke/otomaties-google-reviews-widget
Type:package
pkg:composer/tombroucke/otomaties-google-reviews-widget
Requires
- php: ^8.2
- illuminate/support: *
Requires (Dev)
- laravel/pint: ^1.27
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:
- Go to the Place ID Finder
- Search for your business
- Copy the Place ID (looks like:
ChIJN1t_tDeuEmsRUsoyG83frY4)
2. Create a Google API Key
- Go to Google Cloud Console
- Create a new project or select an existing one
- Go to APIs & Services > Library
- Search for and enable "Places API"
- Go to APIs & Services > Credentials
- Click Create Credentials > API Key
- Copy the API key
- (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.
- Join us on Discord by sponsoring us on GitHub
- Join us on Roots Discourse
- Follow @rootswp on Twitter
- Follow the Roots Blog
- Subscribe to the Roots Newsletter