User Docs Developer Docs | |

CLI Commands

Pubvana ships seven custom Spark commands, located in app/Commands/. All extend CI4's BaseCommand.

Running Commands

cd /var/www/html2
php spark <command> [arguments] [--options]

Command Reference

posts:publish

Class: AppCommandsPublishScheduledPosts

Publishes all posts whose scheduled_at is in the past and status = 'scheduled'. Updates status to 'published' and sets published_at to NOW().

php spark posts:publish

Called by the cron system every 5 minutes. Can be run manually to force immediate publish.

links:check

Class: AppCommandsCheckBrokenLinks

Crawls all published posts and pages, extracts anchor href values, and performs HEAD requests against each URL. Stores results in broken_link_results table (columns: url, source_post_id, http_status, checked_at).

php spark links:check

Expected to be slow on large sites — run from cron, not on-demand.

marketplace:revalidate

Class: AppCommandsRevalidateLicenses

Re-validates all installed licensed extensions against pubvana.net/api/license/validate. Updates marketplace_licenses.is_valid and last_checked.

php spark marketplace:revalidate
php spark marketplace:revalidate --force    # ignores last_checked interval

Options:

  • --force — revalidates all licenses regardless of when they were last checked

pubvana:backup

Class: AppCommandsBackupCommand

Creates a full database dump (mysqldump) and optionally a writable/uploads/ archive. Stores the backup in writable/backups/ as a timestamped .sql.gz file.

php spark pubvana:backup
php spark pubvana:backup --trigger=cron
php spark pubvana:backup --email=admin@example.com

Options:

  • --trigger=X — label included in the filename and activity log (default: 'manual')
  • --email=X — send backup completion notification to this address

pubvana:update

Class: AppCommandsUpdateCommand

Checks for a new core CMS version, downloads it, runs migrations, and optionally sends a notification email.

php spark pubvana:update
php spark pubvana:update --dry-run           # check only, no changes
php spark pubvana:update --email=admin@example.com

Options:

  • --dry-run — report available update without applying it
  • --email=X — notify this address on completion or failure

pubvana:rollback

Class: AppCommandsRollbackCommand

Restores a previously created backup from writable/backups/.

php spark pubvana:rollback 2026-04-01-143000.sql.gz
php spark pubvana:rollback 2026-04-01-143000.sql.gz --email=admin@example.com

Arguments:

  • <filename> — backup filename from writable/backups/ (required)

Options:

  • --email=X — notify this address on completion or failure

wp:import

Class: AppCommandsWordPressImport

Imports posts, categories, tags, and media from a WordPress WXR export XML file.

php spark wp:import /path/to/export.xml
php spark wp:import /path/to/export.xml --dry-run

Arguments:

  • <file> — path to WordPress WXR export file (required)

Options:

  • --dry-run — parse and count importable items without writing to the database

Cron System

Pubvana uses the Pubvana cron system (Commands/Cron.php). Two tasks are registered:

// Commands/Cron.php
$schedule->command('posts:publish')->everyFiveMinutes();
$schedule->command('links:check')->daily();

The scheduler requires a system cron entry:

* * * * * cd /var/www/html2 && php spark cron minute >> /dev/null 2>&1

cron

Pubvana's unified cron command. Runs tasks grouped by frequency: minute, quarterday, or daily.

php spark cron minute

queue:work pubvana

CI4 queue worker for the pubvana queue. Used for async jobs (email sending, social sharing).

php spark queue:work pubvana

Writing Custom Commands

Create a class in app/Commands/ extending BaseCommand:

<?php

namespace AppCommands;

use CodeIgniterCLIBaseCommand;
use CodeIgniterCLICLI;

class MyCommand extends BaseCommand
{
    protected $group       = 'pubvana';
    protected $name        = 'my:command';
    protected $description = 'Does something useful.';

    public function run(array $params): void
    {
        CLI::write('Running...', 'green');
        // your logic here
        CLI::write('Done.', 'green');
    }
}

No registration is needed — Spark auto-discovers commands in app/Commands/.