Artisan Commands

This package registers the following Artisan commands. All commands are available after the package is installed.


Setup & Installation

textstem:post-install

Interactive wizard to run after first installing the package. Prompts to select an installation type (Vanilla - no Jetstream, Jetstream with Livewire, or Jetstream with Inertia) and then publishes config, components, JS/CSS assets, and Jetstream views.

php artisan textstem:post-install

textstem:refresh-assets

Clears the published JS/CSS files from public/vendor/medialight/textstem/ and republishes them from the package. Also ensures required resources/views/wrangler/ subdirectories exist and that the default page view and Prose component views are in place.

Run this after upgrading the package.

php artisan textstem:refresh-assets

textstem:publish-jetstream-views

Force-publishes Jetstream views to the host application. Useful when Jetstream views need to be refreshed separately from a full post-install.

php artisan textstem:publish-jetstream-views

textstem:install-react {--force}

Publishes the React/Inertia rendering source to resources/js/ and offers to set TEXTSTEM_REACT_RENDERING=true. --force overwrites files already published. See React rendering.

php artisan textstem:install-react

textstem:dbseed

Seeds the database with sample data using the package's DatabaseSeeder.

php artisan textstem:dbseed

textstem:approval-roles {--editor=editor} {--publisher=publisher} {--dry-run}

Sets up two roles for content approval: an editor role, whose pages and posts need approval, and a publisher role, which approves and publishes them. Editors get the page, block and post permissions they need to write and send work for review, plus assets, tags, categories and view-dashboard; publish wranglerpages and publish posts are taken away from them. Publishers get the same plus both publish permissions and delete wranglerpages and delete posts. Existing roles are matched by name whatever its case, and keep any other permissions they have, so it is safe to run again.

It then lists what it can't change: roles missing from admin_roles (with the line to use), people with the editor role who can still publish through another role or a permission of their own, and other roles that publish without approval. Use --dry-run to see the changes first. See Setting Up Content Approval.

php artisan textstem:approval-roles --dry-run
php artisan textstem:approval-roles --editor=writer --publisher=sub-editor

Code Generators

textstem:make:pagecomponent {name}

Scaffolds a new Wrangler page component. Creates the component class in app/Wrangler/Components/ and copies the sample view templates into resources/views/wrangler/components/{name}/.

php artisan textstem:make:pagecomponent HeroBlock
php artisan textstem:make:pagecomponent ImageGallery

Files created:

  • app/Wrangler/Components/HeroBlock.php
  • resources/views/wrangler/components/hero-block/ (sample views)

textstem:make:tool {name}

Scaffolds a new admin panel tool. Creates the tool class in app/Tools/ and a default view in resources/views/wrangler/tools/{name}/.

php artisan textstem:make:tool MyCustomTool

Files created:

  • app/Tools/MyCustomTool.php
  • resources/views/wrangler/tools/my-custom-tool/default.blade.php

See extending-textstem.md for the BaseTool contract and how Tools are discovered.

The new tool will automatically appear at /textstem/tools/{name}.


textstem:make:mcp-resource {name}

Scaffolds a new MCP resource class in app/Mcp/Resources/. Implement entries(), handles(), and read() to expose read-only data to AI assistants. See docs/mcp.md for a full walkthrough.

php artisan textstem:make:mcp-resource EventsResource

File created:

  • app/Mcp/Resources/EventsResource.php

textstem:make:mcp-tool {name}

Scaffolds a new MCP tool class in app/Mcp/Tools/. Implement name(), inputSchema(), and call() to expose callable actions to AI assistants. See docs/mcp.md for a full walkthrough.

php artisan textstem:make:mcp-tool ContactTool

File created:

  • app/Mcp/Tools/ContactTool.php

textstem:make:module {name}

Scaffolds a full CRUD module including a model, controller, policy, store/update form requests, views, a Livewire data table, and domain action/filter config builders.

php artisan textstem:make:module Products

Files created:

  • app/Models/Product.php
  • app/Http/Controllers/ProductController.php
  • app/Policies/ProductPolicy.php
  • app/Http/Requests/ProductStoreRequest.php
  • app/Http/Requests/ProductUpdateRequest.php
  • app/Livewire/Tables/ProductTable.php
  • app/Domain/Products/Config/ProductActionBuilder.php
  • app/Domain/Products/Config/ProductFilterBuilder.php
  • resources/views/admin/products/ (index, create, edit, form-inputs views)

The command will prompt before overwriting any file that already exists.

The database table for the model should exist before running this command -- it introspects the live table to decide on Sluggable support and pre-fill the action/filter config. The generated policy also isn't auto-discovered (Textstem overrides Laravel's policy guesser globally) and needs manual Gate::policy(...) registration. Full walkthrough, including this and the controller/policy ability-name mismatch, in extending-textstem.md.


textstem:make:collection {name} [--wc]

Despite its name, this does not create a collection: collections are created in the admin (Collections → Create), which writes their config.json to resources/views/wrangler/posts/{slug}/. What the command does is generate a page block class, app/Wrangler/Components/{Name}.php, for showing the collection's posts on pages. With --wc it also creates resources/views/wrangler/components/{name}/default.blade.php.

Known issue: with --wc, the command copies the raw stub over the class it has just generated, leaving class DummyClass in app/Wrangler/Components/{Name}.php. Rename the class to match the file name by hand.

php artisan textstem:make:collection Events
php artisan textstem:make:collection Events --wc

textstem:make:dashboardwidget {name}

Scaffolds a new Livewire dashboard widget. Creates the component class under app/Livewire/DashboardWidgets/ and a default view under resources/views/livewire/dashboard-widgets/{name}/.

php artisan textstem:make:dashboardwidget RecentActivity

textstem:make:templatecommand {name}

Scaffolds a new template command. Creates the class under app/Wrangler/TemplateCommands/ and copies a starter view folder into resources/views/wrangler/template-commands/{name}/ (the name lower-cased, e.g. latestposts). --template= picks the starter folder: asset, assets, img, img-collection or posts.

Known issue: without --template, the command looks for a sample folder the package doesn't ship and stops with Unknown --template "sample". Pass a --template until this is fixed.

Template commands are the {wrt …} shortcodes editors type into content, not Blade directives. See Template Commands.

php artisan textstem:make:templatecommand LatestPosts --template=posts

Export

textstem:export-component [name] [--all] [--output=]

Exports a Wrangler page component to a ZIP file. The ZIP contains the component class and its view directory, suitable for importing via the Component Manager tool.

If name is omitted, an interactive list of available components is shown.

# Interactive selection
php artisan textstem:export-component

# Export a specific component
php artisan textstem:export-component HeroBlock

# Export all app components as individual ZIPs
php artisan textstem:export-component --all

# Custom output directory
php artisan textstem:export-component HeroBlock --output=/tmp/exports

Only components in app/Wrangler/Components/ are listed and exported (not package-bundled components).

Output defaults to storage/app/exports/{ComponentName}.zip.


textstem:export-widget [name] [--package] [--all] [--output=]

Exports a dashboard widget to a ZIP file suitable for importing via the Install Widget page.

If name is omitted, an interactive list of available widgets is shown. Use --package to export a widget bundled with the package rather than one in your app.

# Interactive selection
php artisan textstem:export-widget

# Export a specific widget
php artisan textstem:export-widget SiteOverview

# Export all app widgets as individual ZIPs
php artisan textstem:export-widget --all

# Export a package-bundled widget (rewrites namespace/view refs for the app)
php artisan textstem:export-widget SiteOverview --package

# Custom output directory
php artisan textstem:export-widget SiteOverview --output=/tmp/exports

ZIP structure produced:

SiteOverview.php          ← widget class (placed at app/Livewire/DashboardWidgets/ on import)
view/
  site-overview/
    default.blade.php     ← views (placed at resources/views/livewire/dashboard-widgets/ on import)

Only widgets in app/Livewire/DashboardWidgets/ are listed by default. Output defaults to storage/app/exports/{WidgetName}.zip.


textstem:export-tool {name} [--output=]

Exports an admin tool to a ZIP file suitable for importing via the Install Tool page at /textstem/tools/install.

The name is normalised — my-tool, MyTool, and my_tool all resolve to MyTool.

php artisan textstem:export-tool MyCustomTool
php artisan textstem:export-tool my-custom-tool
php artisan textstem:export-tool MyCustomTool --output=/tmp

ZIP structure produced:

MyCustomTool.php          ← tool class (placed at app/Tools/ on import)
view/
  default.blade.php       ← views (placed at resources/views/wrangler/tools/my-custom-tool/ on import)

Only tools in app/Tools/ can be exported. If the tool has associated Livewire components or other app files, add them manually under an install/ directory in the ZIP before distributing (e.g. install/app/Livewire/MyComponent.php). These will be copied to the matching project path on import.

Output defaults to storage/app/exports/{ToolName}.zip.


textstem:create-placeholders

Generates placeholder PNG images for each configured image size preset. Reads image_presets from config/textstemapp.php and writes files to storage/app/public/placeholders/{size}.png. Skips sizes that already have a placeholder file.

php artisan textstem:create-placeholders

Run this after changing image preset configuration or setting up a new environment.


Database

textstem:schema-compare [--keep-schema] [--schema-file=]

Compares the schema defined by the package and app migrations against the live database and reports any differences with suggested ALTER TABLE fix-up statements.

The command works in three steps:

  1. Creates a temporary database (same driver as the live connection), runs all migrations into it, then drops it.
  2. Extracts the ideal schema to a JSON snapshot file (default: storage/temp_schema_compare.json).
  3. Diffs the snapshot against the live database, reporting missing tables, missing or extra columns, type/nullability/default mismatches, and missing or different indexes.
php artisan textstem:schema-compare

# Keep the extracted JSON snapshot after the run
php artisan textstem:schema-compare --keep-schema

# Write the snapshot to a custom path
php artisan textstem:schema-compare --schema-file=/tmp/my-schema.json

Requires CREATE DATABASE privilege for MySQL/MariaDB. For SQLite, a temporary file is used instead.


textstem:migrations:sync [--batch=1]

Inserts all migration filenames found in database/migrations/ into the migrations table without actually running them. Useful when SQL has been applied manually to a production database and you need to bring the migrations ledger into sync.

php artisan textstem:migrations:sync

# Assign migrations to a specific batch number
php artisan textstem:migrations:sync --batch=5

Only inserts migrations not already recorded in the table. Already-recorded entries are left untouched.


textstem:model-check

Checks each Eloquent model against its corresponding database table and reports mismatches between fillable fields, casts, and the actual columns present.

php artisan textstem:model-check

textstem:normalize-asset-types {--dry-run}

Resets asset type values that were stored as raw MIME types (for example application or video/mp4) to one of image, video, audio or file. --dry-run lists the changes without making them.

php artisan textstem:normalize-asset-types --dry-run

Maintenance

textstem:security-audit {--notify} {--notify-mode=on_alert} {--emails=}

Checks Composer dependencies, the PHP and OS versions, and the web server version against known CVEs, and has the AI provider assess the results. --notify sends an email: with --notify-mode=on_alert (the default) only when vulnerabilities are found, with always every run. --emails is a comma-separated recipient list. It can also be run and scheduled from Tools → Security Audit.

php artisan textstem:security-audit --notify --emails=ops@example.com

forms:prune-submissions {--dry-run}

Only available with FORMS_ENABLED=true. Removes form answers past their form's retention period, and deleted answers (and their files) older than FORMS_PURGE_DELETED_AFTER_DAYS. --dry-run counts what would be removed. Scheduled daily at 03:45.


cache:manage [action] [--warm-up]

Manages the application cache. The action argument defaults to clear.

Action Effect
clear Clears application, route, config, view, and compiled caches
warm-up Pre-warms frequently accessed content (recent news posts)

Use --warm-up with the clear action to clear and immediately warm up in one step.

php artisan cache:manage clear
php artisan cache:manage warm-up
php artisan cache:manage clear --warm-up

Note: unlike other Textstem commands, this uses the cache: prefix, not textstem:.


textstem:update-llm-pricing

Views and manages the LLM token pricing rates used to estimate cost in the OpenAI Usage admin tool. With no options, displays the current pricing table and its source (package defaults or local override).

# View current pricing table
php artisan textstem:update-llm-pricing

# Verify pricing against official sources (interactive)
php artisan textstem:update-llm-pricing --verify

# Update rates for an existing model
php artisan textstem:update-llm-pricing --model=gpt-4o --input=2.50 --output=10.00

# Add a new model (fails without --add if the model is not already listed)
php artisan textstem:update-llm-pricing --model=gpt-5 --input=10.00 --output=40.00 --add

# Remove a model from the local override file
php artisan textstem:update-llm-pricing --remove=gpt-4

# Delete the local override and revert to package defaults
php artisan textstem:update-llm-pricing --reset

Changes are written to storage/app/llm-pricing.json in the host application, which takes precedence over the package-bundled resources/llm-pricing.json. Use --reset to discard local overrides.

The --verify flag shows the full pricing table alongside links to the official OpenAI and Anthropic pricing pages. Confirming the prompt stamps a _verified_at date in the pricing file. If pricing is unverified or stale, a warning banner is shown in the OpenAI Usage admin dashboard.

See openai-token-usage.md for full details.


textstem:health-check [--notify]

Checks the health of the application and displays a status table. Checks performed:

Check What is verified
Database Connection can be established
Cache Write and read a test value
Storage Write, read, and delete a test file
Disk space Warns if storage partition is >90% full
PHP version PHP ≥ 8.1 is installed

With --notify, logs failure details (email notification requires ERROR_NOTIFICATION_EMAIL to be set in .env).

php artisan textstem:health-check
php artisan textstem:health-check --notify

textstem:sitemap:generate

Builds a sitemap from published, public, listed WranglerPage records and writes it to public/sitemap.xml. Uses Spatie\Sitemap\Sitemap directly -- no HTTP crawling.

php artisan textstem:sitemap:generate

textstem:prune-reports [--dry-run]

Deletes old accessibility and SEO reports from the database according to the retention period configured in each service. Use --dry-run to preview what would be deleted without making any changes.

php artisan textstem:prune-reports
php artisan textstem:prune-reports --dry-run

textstem:prune-events [--dry-run]

Deletes old rows from the events table older than the configured retention period (textstemapp.events.retention_days, default 90 days). Publications (published and unpublished entries, from content approval) are kept. Use --dry-run to preview how many rows would be deleted without making any changes.

Scheduled automatically by the package on Mondays at 03:30.

php artisan textstem:prune-events
php artisan textstem:prune-events --dry-run

Configure the retention period in config/textstemapp.php or .env:

EVENTS_RETENTION_DAYS=90

textstem:publish-due

Publishes approved pages and posts whose scheduled time has come (content approval). One that can't be published -- the live item changed since its draft was made, or the publisher who scheduled it can no longer publish -- goes back to review and publishers are emailed. Scheduled automatically by the package every minute.


textstem:clear-idle-drafts [--dry-run]

Clears drafts of live pages and posts nobody has worked on for textstemapp.approvals.idle_draft_days (TEXTSTEM_APPROVALS_COPY_DAYS, default 90; 0 keeps them), and emails the people who worked on each one a week before. Drafts waiting for review or scheduled are kept. Scheduled automatically by the package daily at 04:00.


textstem:normalize-asset-paths [--dry-run] [--force]

Scans the assets table for records storing full server paths (e.g. /var/www/..., /home/..., or paths containing storage/app/) and normalises them to relative paths. Use --dry-run to preview changes. Without --force, the command will ask for confirmation before applying updates.

php artisan textstem:normalize-asset-paths
php artisan textstem:normalize-asset-paths --dry-run
php artisan textstem:normalize-asset-paths --force

textstem:clear-snapshot-throttles [--type=] [--id=]

Clears version snapshot throttles so that a new snapshot can be created immediately, bypassing the normal throttle window.

# Clear all throttles
php artisan textstem:clear-snapshot-throttles

# Clear throttle for a specific page or component
php artisan textstem:clear-snapshot-throttles --type=page --id=42
php artisan textstem:clear-snapshot-throttles --type=component --id=7

Note: this command exists in the package but is not registered by default. Add it to your app/Console/Kernel.php commands array if needed.


textstem:page-screenshots [--check] [--all] [--page=*] [--queue]

Checks the live page screenshot setup, or takes screenshots for the Pages admin's cards and column browser (see installation.md, Step 13).

Option Effect
--check Reports whether screenshots are turned on and the tools are found, then takes a throwaway test screenshot. A failure names the likely fix (missing puppeteer, Chrome, system libraries, sandbox or Node). A passing check also clears a pause after repeated failures.
--all Captures every page now.
--page=ID Captures the given pages (repeatable).
--queue With --all or --page, queues the captures instead of taking them now.
php artisan textstem:page-screenshots --check
php artisan textstem:page-screenshots --all
php artisan textstem:page-screenshots --page=17 --page=18 --queue

textstem:maintenance-schedule

Displays the recommended maintenance schedule for the package with ready-to-paste code for app/Console/Kernel.php. Does not execute any tasks itself.

php artisan textstem:maintenance-schedule

The output includes recommended daily, weekly, and monthly tasks covering health checks, sitemap generation, report pruning, cache management, and queue maintenance.


Scheduling

The package adds these to Laravel's scheduler itself, so you don't add them to your own schedule. The host app only needs the usual cron entry that runs php artisan schedule:run every minute.

Command Runs Added by
textstem:health-check Daily, 01:00 Always
cache:manage clear --warm-up Mondays, 01:30 Always
textstem:prune-reports Daily, 03:00 Always
textstem:prune-events Mondays, 03:30 Always
textstem:publish-due Every minute Always (content approval)
textstem:clear-idle-drafts Daily, 04:00 Always (content approval)
forms:prune-submissions Daily, 03:45 Only with FORMS_ENABLED=true
textstem:security-audit Daily or weekly Only when turned on in Tools → Security Audit

textstem:sitemap:generate is not scheduled. If you want a fresh sitemap every day, add it to your own schedule:

// routes/console.php (Laravel 11+) or app/Console/Kernel.php
Schedule::command('textstem:sitemap:generate')->dailyAt('02:00');

The scheduled health check runs without --notify. To be emailed on failure, schedule your own textstem:health-check --notify as well.

Run php artisan textstem:maintenance-schedule to print a longer list of suggested housekeeping tasks (queue retries, log and backup clean-up). Treat it as suggestions: it still lists app:health-check, an old name for textstem:health-check.

esc