- Add OpenSpec experimental workflow with commands (opsx-apply, opsx-archive, opsx-explore, opsx-propose) - Add Serena memory system for project context - Implement User API (UserController, UserModel, routes) - Add Specimen delete endpoint - Update Test definitions and Routes - Sync API documentation (OpenAPI) - Archive completed 2026-03-08-backend-specs change
7.7 KiB
7.7 KiB
CLQMS Suggested Commands
Database Commands
Migrations
# Run all pending migrations
php spark migrate
# Run specific migration
php spark migrate [migration_file]
# Rollback last batch of migrations
php spark migrate:rollback
# Rollback and re-run migrations
php spark migrate:refresh
# Refresh and seed database
php spark migrate:refresh --seed
# Check migration status
php spark migrate:status
Database Seeding
# Run all seeders
php spark db:seed
# Run specific seeder
php spark db:seed DBSeeder
# Create new database
php spark db:create
Database Query
# Get table information
php spark db:table [table_name]
Testing Commands
PHPUnit Tests
# Run all tests
vendor/bin/phpunit
# Run specific test file (IMPORTANT for debugging)
vendor/bin/phpunit tests/feature/UniformShowTest.php
vendor/bin/phpunit tests/feature/Patient/PatientCreateTest.php
# Run tests in specific directory
vendor/bin/phpunit tests/feature/Patient/
# Run tests with coverage (text output)
vendor/bin/phpunit --coverage-text=tests/coverage.txt -d memory_limit=1024m
# Run tests with coverage (HTML report)
vendor/bin/phpunit --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
# Run with verbose output
vendor/bin/phpunit --verbose
# Run specific test method
vendor/bin/phpunit --filter testCanCreatePatient
Code Generation Commands
Generate Code Files
# Generate new model
php spark make:model ModelName
# Generate new controller
php spark make:controller ControllerName
# Generate new migration
php spark make:migration MigrationName
# Generate new seeder
php spark make:seeder SeederName
# Generate new test
php spark make:test TestName
# Generate scaffold (complete set)
php spark make:scaffold ModelName
Development Server
Start Development Server
# Start CodeIgniter dev server (default port 8080)
php spark serve
# Start on specific port
php spark serve --port=8080
# Start with specific host
php spark serve --host=0.0.0.0
Cache Management
Clear Caches
# Clear application cache
php spark cache:clear
# Show cache information
php spark cache:info
# Clear debug bar JSON files
php spark debugbar:clear
# Clear log files
php spark logs:clear
System Utilities
Configuration & Environment
# Get current environment
php spark env
# Set environment
php spark env development
# Check configuration values
php spark config:check
# Check php.ini values (for production)
php spark phpini:check
# Verify namespaces
php spark namespaces
Routes
# Display all routes
php spark routes
# Check filters for a route
php spark filter:check
Optimization
# Optimize for production
php spark optimize
Utility Commands
Encryption
# Generate new encryption key (writes to .env)
php spark key:generate
Publish
# Publish predefined resources
php spark publish
General Utility Commands (Windows)
File & Directory Operations
# List files in current directory
dir
# List files with details
dir /a
# Change directory
cd path\to\directory
# Go to parent directory
cd ..
# Create directory
mkdir directory_name
# Remove directory (empty)
rmdir directory_name
# Remove directory with contents
rmdir /s /q directory_name
# Copy file
copy source_file destination
# Move/Rename file
move source destination
# Delete file
del filename
# Search for file
dir /s filename
File Content Operations
# Display file content
type filename
# Display file content page by page
more filename
# Search for text in file
findstr "pattern" filename
# Search recursively
findstr /s /i "pattern" *.php
Git Commands
# Check git status
git status
# View changes
git diff
# View staged changes
git diff --staged
# Add files to staging
git add .
# Add specific file
git add path/to/file
# Commit changes
git commit -m "commit message"
# Push to remote
git push
# Pull from remote
git pull
# View commit history
git log
# View commit history with graph
git log --graph --oneline
# Create new branch
git checkout -b branch_name
# Switch branch
git checkout branch_name
# Merge branch
git merge branch_name
# View branches
git branch
Process Management
# List running processes
tasklist
# Kill process by PID
taskkill /PID pid_number
# Kill process by name
taskkill /IM process_name.exe
# Kill process forcefully
taskkill /F /PID pid_number
Network Operations
# Check port usage
netstat -an | findstr :port
# Test network connectivity
ping hostname
# View active connections
netstat -an
After Task Completion Checklist
When completing a task, run the following commands to ensure code quality:
1. Run Tests
# Run all tests
vendor/bin/phpunit
# If tests fail, run specific test file for debugging
vendor/bin/phpunit tests/feature/[SpecificTestFile].php
2. Check for Linting Issues (if configured)
# Check for PHP syntax errors
php -l app/Controllers/YourController.php
php -l app/Models/YourModel.php
# Run any custom linting tools if configured in composer.json
composer test # if 'test' script includes linting
3. Type Checking (if configured)
# Run static analysis tools if configured
vendor/bin/phpstan analyse # if phpstan is installed
vendor/bin/psalm # if psalm is installed
4. Database Verification
# Check migration status
php spark migrate:status
# If you created a migration, run it
php spark migrate
5. API Documentation Update (CRITICAL)
# After modifying ANY controller, MUST update api-docs.yaml
# This is a manual process - edit public/api-docs.yaml
# Verify YAML syntax (optional, if yamllint is available)
yamllint public/api-docs.yaml
6. Code Review Checklist
- All tests passing
- No PHP syntax errors
- Database migrations applied (if any)
- API documentation updated (
public/api-docs.yaml) - Code follows style conventions (see
code_style_conventions.md) - Proper error handling in place
- Input validation implemented
- JWT authentication required where needed
- UTC date handling via BaseModel
- Soft delete using
DelDatewhere applicable - ValueSet lookups properly used and cached cleared if modified
7. Verify API Endpoints (if applicable)
# If you have curl or a REST client, test the endpoints
# Example using curl:
curl -X GET http://localhost:8080/api/patient -H "Cookie: token=your_jwt_token"
Common Workflows
Creating a New API Endpoint
- Create controller:
php spark make:controller ControllerName - Create model:
php spark make:model ModelName - Create migration (if new table):
php spark make:migration MigrationName - Run migration:
php spark migrate - Add routes in
app/Config/Routes.php - Implement controller methods following pattern
- Create tests:
php spark make:test Feature/EndpointNameTest - Run tests:
vendor/bin/phpunit tests/feature/EndpointNameTest.php - Update
public/api-docs.yaml - Verify with test client
Debugging a Failing Test
- Run specific test file:
vendor/bin/phpunit tests/feature/SpecificTest.php - Add debug output:
var_dump($result); die();temporarily - Check database state: View with database client
- Check logs:
writable/logs/directory - Run with verbose:
vendor/bin/phpunit --verbose - Isolate specific test:
vendor/bin/phpunit --filter testMethodName
Working with ValueSets
- Create/edit JSON file:
app/Libraries/Data/valuesets/{name}.json - Clear cache:
ValueSet::clearCache();(in code) or via code - Verify via API: GET
/api/valueset/{name} - Test lookup:
ValueSet::get('name')in controller/model