Skip to main content

Commands

make:polyslug

php artisan make:polyslug Page

Scaffolds a sluggable Eloquent model at app/Models/{Name}.php, pre-wired with the #[Polyslug] attribute, the HasPolyslug trait and the Sluggable interface. The generated attribute uses source: 'title' — change it to the column your model actually slugs from.

An existing file is never overwritten: the command reports the conflict and exits non-zero.

ArgumentDescription
nameThe model class name. Only the base name is used, so Blog/Page yields Page.

polyslug:backfill

php artisan polyslug:backfill "App\Models\Page"
php artisan polyslug:backfill "App\Models\Page" --locale=de
php artisan polyslug:backfill "App\Models\Page" --queue --chunk=500
php artisan polyslug:backfill "App\Models\Page" --queue --on-queue=bulk --on-connection=redis

Backfills current slugs for a sluggable model's existing rows. Rows that already have a current slug for the target locale are skipped, so the command is safe to run repeatedly.

Argument / optionDefaultDescription
model(required)The fully-qualified model class. Must be an Eloquent model implementing Sluggable, or the command errors and exits non-zero.
--localethe app localeLocale to backfill.
--queueoffDispatch chunked Polyslug\Jobs\BackfillSlugsJob jobs instead of running inline.
--chunk1000Rows per queued job.
--on-queuepolyslug.backfill.queueQueue name for the dispatched jobs. A backfill on the default queue blocks everything behind it for as long as the table takes.
--on-connectionpolyslug.backfill.connectionQueue connection for the dispatched jobs.

See Backfilling existing rows.

polyslug:sitemap

php artisan polyslug:sitemap --path=public/sitemap.xml

Generates an XML sitemap with hreflang alternates for the models registered in polyslug.sitemap.types. Rows are read in keyset chunks; the rendered document is assembled in memory before it is written.

OptionDefaultDescription
--path(none)Write the XML to this file. Without it, the XML goes to standard output.

Requires a bound Polyslug\Contracts\PolyslugUrlResolver; without one the command prints an error and exits non-zero. See Sitemaps.

polyslug:doctor

php artisan polyslug:doctor

Diagnoses the setup: the encoder configuration, the token settings, how much room the token spaces have left, the uniqueness-guaranteeing indexes, and the resolution gates. It exits non-zero if the configured encoder — or a legacy decoder — is not a valid IdentityEncoder, if a token length or alphabet cannot build a scheme, or if a required unique index is missing (for example because the migrations never ran).

The token-settings check is the one to run after editing polyslug.random_token, polyslug.sequential_token or polyslug.short_links: without it, an unbuildable setting first refuses while a URL is being rendered, in production.

It also reports every registered type that never overrode polyslugResolveQuery(). That is a report, not a failure: such a model resolves any slug to any row, which is correct for public content and an authorization gap for anything owner-scoped. The command cannot tell which you meant, so it names the models and leaves the call to you.

It also reports how full each token width is, once a width is at least a quarter used:

! identity tokens: 400 of 1,296 2-character tokens are taken (31%).
New tokens widen to 3 characters as this fills.

Also a report and never a failure — a filling width is not a fault, and on a counted scheme it is exactly what is supposed to happen. It is there so a short token setting that is running out is visible before it runs out.

See Diagnostics.