Search by

metasyncsite / laravel-metasync-client

metasyncSite

Laravel client for MetaSync: sync page meta tags and redirects with the MetaSync SaaS

Package info

github.com/metasyncSite/laravel-metasync-client

pkg:composer/metasyncsite/laravel-metasync-client

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-09-09 20:53 UTC

This package is auto-updated.

Last update: 2026-09-09 20:58:23 UTC


README

Syncs your Laravel site's meta tags and redirects with MetaSync.

Installation

composer require metasyncsite/laravel-metasync-client
php artisan migrate

.env:

METASYNC_URL=https://app.metasync.site
METASYNC_TOKEN=<project token from MetaSync>

Exposing your pages (required for push)

Implement the PageCollector contract — it yields the site's pages:

use MetaSyncClient\Contracts\PageCollector;

class AppPageCollector implements PageCollector
{
    public function collect(): iterable
    {
        foreach (Product::query()->cursor() as $product) {
            yield [
                'url_path' => '/products/'.$product->slug,
                'lang' => 'uk',
                'page_type' => 'product',
                'title' => $product->meta_title,
                'description' => $product->meta_description,
                'h1' => $product->name,
                'http_status' => 200,
            ];
        }
    }
}

Then bind it in AppServiceProvider::register():

$this->app->bind(PageCollector::class, AppPageCollector::class);

Commands

Command Description
metasync:push [--dry-run] Push the site's pages to MetaSync
metasync:pull [--full] Pull edited meta and redirects into the local cache tables
metasync:sync push + pull
metasync:webhook [url] [--remove] Register a webhook for instant change delivery

metasync:pull registers itself on the scheduler every 15 minutes as a fallback for when the webhook cannot reach the site (disable with METASYNC_SCHEDULE_PULL=false, change the schedule with METASYNC_SCHEDULE_CRON).

Rendering meta on pages

The simplest way is the directive in your layout's <head> — it outputs <title>, description and robots, and renders nothing for pages without an entry:

<head>
    @metasyncHead
</head>

Or resolve entries directly via the facade or resolver (prefers the exact language with a fallback to any; tolerates a trailing-slash mismatch):

$meta = MetaSync::forRequest();            // or app(\MetaSyncClient\MetaResolver::class)
$meta = MetaSync::forPath('/about', 'uk');
<title>{{ $meta?->title ?? config('app.name') }}</title>
@if($meta?->description)<meta name="description" content="{{ $meta->description }}">@endif
@if($meta?->noindex)<meta name="robots" content="noindex">@endif

<h1>{{ $meta?->h1 ?? $product->name }}</h1>

Redirects

The HandleRedirects middleware registers automatically (disable with METASYNC_REDIRECTS=false) and applies active redirects from MetaSync to all GET requests.

Instant change delivery

  1. php artisan metasync:webhook — registers POST /metasync/webhook in MetaSync and prints the secret.
  2. Add METASYNC_WEBHOOK_SECRET=... to your .env.
  3. When meta changes in MetaSync, the service pings your site, the package queues a pull and the changes apply automatically.

Tests

composer install
composer test