CLI Commands
CLI Commands
OpenAPI Specification
OpenAPI is generated dynamically from record configuration at request time:
GET /{api_prefix}/docs/openapi
GET /{api_prefix}/docs/openapi.json
GET /{api_prefix}/docs/llms.mdx
GET /{api_prefix}/docs/llms.txt/{api_prefix}/docs/openapi.json is the recommended machine endpoint for public docs mode, returned with application/vnd.oai.openapi+json. /{api_prefix}/docs/llms.mdx (or llms.txt) provides an AI-oriented markdown contract that points to the OpenAPI schema and key endpoint patterns.
Use the bundled Scalar page to browse the API documentation:
GET /api-docs
GET /api-docs/openapi.jsonDocs access mode is configurable via config/record.php:
'api_docs' => [
'is_private' => env('RECORD_API_DOCS_PRIVATE', false),
'access_token_key' => 'access_token',
'login_api' => '/v1/auth/login',
'email' => env('RECORD_API_DOCS_EMAIL'),
],- When
is_private=false(orapi_docsconfig is missing),/api-docsis public. - When
is_private=true,/api-docsshows a login form and logs in through internal proxy route/api-docs/auth/login. - In private mode, schema is served from
/api-docs/openapi.jsonand requires docs session token. - In private mode, API docs routes under
/{api_prefix}/docs/*return404to prevent anonymous schema leakage. login_apican be a relative path (/v1/auth/login) or absolute URL (https://api.example.com/v1/auth/login) based on client project routing.access_token_keycontrols how token is extracted from login response payload.email(optional) enforces a fixed docs login account for additional protection.
The generated OpenAPI 3.0 schema includes:
Enhanced Schema Generation:
- Full Schema: Complete model schema with all properties
- Read Schema: Optimized for GET responses (includes computed fields, relationships)
- Write Schema: Optimized for POST/PUT requests (excludes read-only fields)
Automatic Documentation:
- Dynamic CRUD endpoints for all configured tables
- RPC function endpoints (global and table-specific)
- Comprehensive parameter documentation (pagination, filtering, sorting)
- Detailed response schemas with examples
- Security schemes (Bearer token authentication)
Smart Table Detection:
- Automatically discovers database tables
- Generates appropriate tags and descriptions
- Includes relationship documentation
- Supports custom table configurations
Compatibility:
- Compatible with Swagger UI, Postman, and other OpenAPI tools
Example Generated Features:
- RESTful endpoints:
GET /{prefix}/{table},POST /{prefix}/{table}, etc. - RPC endpoints:
GET|POST|PUT|PATCH|DELETE /{prefix}/rpc/{functionName},GET|POST|PUT|PATCH|DELETE /{prefix}/{table}/rpc/{functionName} - Advanced filtering and pagination parameters
- Comprehensive error response documentation
Setup Package
php artisan record-api:setupPublishes default configurations for:
config/record.php- Dynamic table and global function loader configurationconfig/records/tables- Per-tableRecordTableTypefilesconfig/records/globalFunctions- Global RPC function group filesconfig/audit.php- Audit logging settingsconfig/record-api.php- Package settings (auth guard, OpenAPI output)
Record Table & Cache Management
# Create a new per-table RecordTableType config (config/records/tables/{name}.php)
php artisan record-api:record customers
# Clear cached query results (kept in the Laravel cache)
php artisan cache:clear
# Sync RecordTableType columns in config/records/tables from DB schema
php artisan record-api:sync-record-columns
# Clean old audit logs based on retention policy
php artisan record-api:clean-audit-logs
# Clean audit logs with options
php artisan record-api:clean-audit-logs --dry-run
php artisan record-api:clean-audit-logs --force --days=30
php artisan record-api:clean-audit-logs --batch-size=500Audit Log Cleanup
The package includes a powerful CLI command for cleaning old audit logs based on your retention policy.
Configuration
Set the retention period in your audit configuration:
// config/audit.php
'retention_days' => env('AUDIT_LOG_RETENTION_DAYS', 365),Command Options
--dry-run- Show what would be deleted without actually deleting--force- Force deletion without confirmation prompt--days=N- Override retention days from config--batch-size=N- Number of records to delete per batch (default: 1000)
Usage Examples
# Basic cleanup (uses config retention_days)
php artisan record-api:clean-audit-logs
# Dry run to see what would be deleted
php artisan record-api:clean-audit-logs --dry-run
# Force cleanup without confirmation
php artisan record-api:clean-audit-logs --force
# Override retention period to 30 days
php artisan record-api:clean-audit-logs --days=30
# Use smaller batch size for large datasets
php artisan record-api:clean-audit-logs --batch-size=500
# Combine options
php artisan record-api:clean-audit-logs --dry-run --days=90Features
- Safe by default: Requires confirmation unless
--forceis used - Batch processing: Deletes records in configurable batches to prevent database locks
- Progress tracking: Shows real-time progress with progress bar
- Statistics: Reports total deleted and remaining records
- Dry run mode: Preview what would be deleted without making changes
- Configurable: Respects audit configuration or allows override