Download the PHP package depa/sulu-google-reviews-bundle without Composer

On this page you can find all versions of the php package depa/sulu-google-reviews-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sulu-google-reviews-bundle

SuluGoogleReviewsBundle

php workflow symfony workflow License: MIT GitHub Tag Supports Sulu 3.0 or later

Symfony bundle for Sulu CMS 3 that fetches Google Places reviews via the Places API, stores them filtered (≥ 4 stars) in a dedicated database table, and provides a native Sulu admin interface for moderation. Frontend output is rendered through a flexible Sulu block.

Available Languages: 🇩🇪 Deutsch


Requirements


Installation

1. Install via Composer

2. Register bundle

With Symfony Flex the bundle is registered in config/bundles.php automatically on composer require. If you don't use Flex, add it manually:

3. Import admin routes

Add to config/routes/routes_admin.yaml:

4. Set environment variables

The bundle ships empty defaults for both variables, so no .env entry is required — the application boots without them. On the server, set the real values in .env.local (never commit):

Find your Place ID on Google Maps Platform. If the values are empty, the import command aborts with a hint.

Alternatively, set the values (or different env vars) via the bundle configuration:

5. Update the database schema

Creates the depa_googlereviews_reviews table.

6. Clear cache

7. Wire the admin field type (frontend build)

The admin detail view uses read-only React field types whose source ships as an npm package inside the bundle (Resources/js). Wire it into the project's admin build like any other Sulu admin JS package:

  1. Reference the package in assets/admin/package.json:

  2. Import it in the admin entry file (assets/admin/app.js):

  3. Install dependencies and build the admin assets:

Note: Sulu cannot compile a bundle's admin JS on its own — registration and build always run through the project. This step is therefore required once on the project side.


Integrating the Sulu Block

Register block type in section template

Add to config/templates/blocks/block--section.xml under <types>:

The "Google Reviews" block will now appear in the Sulu admin editor when adding sub-blocks within a section.

Block fields in editor

Field Description
Title Optional heading above the reviews
Limit Number of reviews to display (default: 3)
Sort Sort mode (see below)
Empty Text Message shown when no reviews are available (optional; falls back to a default)

Sort modes

Value Behavior
By Date Newest reviews first
By Rating Highest star rating first
Custom Order Sorted by the "Sort Order" field of individual reviews

Fetching reviews

Manual fetch

Automated fetch via cronjob

The command imports new reviews (≥ 4 stars) and, for existing entries, updates text, rating, profile photo and relative time. Manual moderation fields (blocked, custom sort order) are preserved.

Fetching the newest reviews instead of "most relevant" (optional)

By default the command fetches the reviews Google ranks as most relevant. The modern Places API (New) offers no sort option, so it always returns that set. To fetch the newest reviews instead, pass --newest:

This uses the Legacy Places API (reviews_sort=newest) — the only Google endpoint that can sort reviews. It requires:

If the legacy API is unavailable, the run logs a warning for the affected locale and imports nothing for it. Without --newest the behaviour is unchanged.

Multilingual support

The command fetches reviews per webspace locale (resolved automatically via Sulu's WebspaceManager). For each configured language, Google's translated version of the review text and the localized relative time are stored — all in the same database row. A review therefore stays a single entry in the admin regardless of the number of languages.

Backfilling missing translations (optional)

Because Google only returns the latest ~5 reviews, older reviews do not get a translation from the fetch alone when a newly added language appears. A separate command translates the stored original text into all missing webspace languages via a translation service:

Google API notes


Moderation in Sulu Admin

After installation, the menu item "Google Reviews" appears in the Sulu backend (icon: comment).

List view

Shows all imported reviews with author, star rating, date, block status, and sort order.

Detail view

Section Fields Editable
Review (imported from Google) read-only display: author, stars, date, original language and the review text per webspace language No
Moderation & Display Block review, sort order Yes

The review itself is rendered through the read-only admin field type google_review_display (see Installation, step 7).

Block review

Blocked reviews won't appear on the frontend and are excluded from get_stored_google_reviews() results.

Custom sort order

The Sort Order field is used when the block's sort mode is set to "Custom Order".

When assigning an already-taken sort position, all other entries at that position and above are automatically shifted up by one.


Twig functions (direct usage)

The bundle provides two Twig functions for use anywhere in templates, independent of the Sulu block.

get_stored_google_reviews(limit, sort)

Parameter Type Default Possible Values
limit int 5 Any positive integer
sort string 'date' 'date', 'rating', 'custom'

google_review_relative_time(timestamp, locale)

Returns a computed, always-current relative time (e.g. "3 months ago") from the timestamp — not Google's stored, ageing string. Localized for ~280 locales via Carbon (diffForHumans).

Parameter Type Description
timestamp int review.createdAtTimestamp
locale string Target locale, e.g. app.request.locale

Example:

Available review properties

Property Type Description
authorName string Reviewer name
profilePhotoUrl string\|null URL to Google profile photo
rating int Star rating (4 or 5)
getText(locale) string Review text for the locale, falling back to the original text
originalText string\|null Original text in its source language (fallback)
originalLanguage string\|null Language code of the original text
createdAtTimestamp int Created date as Unix timestamp
blocked bool Block status (when accessing the repository directly)
sortOrder int Custom sort position

Note: the review text is locale-specific — use review.getText(app.request.locale) (review.text without an argument returns the original text as a fallback). The relative time is computed via google_review_relative_time(...) instead of being read from a stored value.


Frontend styling

The template uses Bootstrap 5 for grid layout and follows BEM naming conventions:

BEM Class Element
.google-reviews Wrapper <section>
.google-reviews__title Optional heading
.google-reviews__card Individual review card
.google-reviews__author Author area
.google-reviews__avatar Profile photo
.google-reviews__avatar--fallback Initial fallback without photo
.google-reviews__author-name Author name
.google-reviews__rating Stars container
.google-reviews__star Single star
.google-reviews__star--filled Filled star
.google-reviews__text Review text
.google-reviews__time Relative time
.google-reviews__empty Fallback message when no reviews

Template location: Resources/views/includes/blocks/block--google-reviews.html.twig

Customizing the template

Once the bundle is installed via Composer, override the template in your main project:

  1. Create the file:

  2. Copy the content from the bundle and customize (CSS classes, HTML structure, etc.)

Twig searches for templates first in the main project, then in bundles — your version will be used automatically.


Architecture overview

The bundle extension automatically registers via PrependExtensionInterface:

So no manual entries in sulu_admin.yaml or twig.yaml are required. Only the admin field type must be wired into the webpack build on the project side (see Installation, step 7).


All versions of sulu-google-reviews-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
sulu/sulu Version ^3.0
symfony/config Version ^7.0
symfony/dependency-injection Version ^7.0
symfony/framework-bundle Version ^7.0
symfony/http-client Version ^7.0
symfony/http-kernel Version ^7.0
doctrine/doctrine-bundle Version ^2.13
doctrine/orm Version ^3.0
twig/twig Version ^3.9
nesbot/carbon Version ^2.72 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package depa/sulu-google-reviews-bundle contains the following files

Loading the files please wait ...