Marketplace

symfony:daily-workflow

Daily development workflow for Symfony projects including common tasks, debugging, and productivity tips

$ 安裝

git clone https://github.com/MakFly/superpowers-symfony /tmp/superpowers-symfony && cp -r /tmp/superpowers-symfony/skills/daily-workflow ~/.claude/skills/superpowers-symfony

// tip: Run this command in your terminal to install the skill


name: symfony:daily-workflow description: Daily development workflow for Symfony projects including common tasks, debugging, and productivity tips

Daily Symfony Development Workflow

Starting Your Day

1. Update Dependencies (if needed)

# Pull latest code
git pull origin main

# Update dependencies
composer install

# Run migrations
bin/console doctrine:migrations:migrate --no-interaction

# Clear cache
bin/console cache:clear

2. Start Services

# Docker Compose
docker compose up -d

# Or Symfony Docker
docker compose up -d --wait

# Start Symfony server (if not using Docker)
symfony server:start -d

3. Check Status

# Verify database connection
bin/console doctrine:query:sql "SELECT 1"

# Check messenger transports
bin/console messenger:stats

# Verify cache is working
bin/console cache:pool:list

Common Development Tasks

Creating New Features

# 1. Create entity
bin/console make:entity Product

# 2. Create migration
bin/console make:migration

# 3. Run migration
bin/console doctrine:migrations:migrate

# 4. Create controller
bin/console make:controller ProductController

# 5. Create form (if needed)
bin/console make:form ProductType

# 6. Create test
bin/console make:test WebTestCase ProductControllerTest

Working with Doctrine

# Validate mapping
bin/console doctrine:schema:validate

# Show SQL that would be executed
bin/console doctrine:schema:update --dump-sql

# Generate migration from entity changes
bin/console make:migration

# Load fixtures
bin/console doctrine:fixtures:load

# Reset database
bin/console doctrine:database:drop --force
bin/console doctrine:database:create
bin/console doctrine:migrations:migrate --no-interaction
bin/console doctrine:fixtures:load --no-interaction

Working with Messenger

# Process messages
bin/console messenger:consume async -vv

# Process with limits
bin/console messenger:consume async --limit=10 --time-limit=60

# View failed messages
bin/console messenger:failed:show

# Retry failed messages
bin/console messenger:failed:retry --all

# Stop workers gracefully
bin/console messenger:stop-workers

Debugging

Debug Tools

# Debug routes
bin/console debug:router
bin/console debug:router api_products_get_collection

# Debug container/services
bin/console debug:container
bin/console debug:container ProductService
bin/console debug:autowiring Product

# Debug configuration
bin/console debug:config framework
bin/console debug:config api_platform

# Debug event dispatcher
bin/console debug:event-dispatcher
bin/console debug:event-dispatcher kernel.request

Profiler

# Enable profiler (dev only)
# Visit: /_profiler

# Check latest profiles via CLI
bin/console profiler:list

Logging

# Tail logs
tail -f var/log/dev.log

# Filter logs
grep "ERROR" var/log/dev.log
grep "doctrine" var/log/dev.log

Dump and Die

// In code
dump($variable);    // Dump but continue
dd($variable);      // Dump and die

// In Twig
{{ dump(variable) }}

Testing Workflow

Running Tests

# All tests
./vendor/bin/phpunit
# Or with Pest
./vendor/bin/pest

# Specific test file
./vendor/bin/pest tests/Functional/Api/ProductTest.php

# Specific test method
./vendor/bin/pest --filter "creates product"

# With coverage
./vendor/bin/pest --coverage --min=80

# Parallel execution
./vendor/bin/pest --parallel

TDD Cycle

# 1. Write failing test
./vendor/bin/pest tests/Unit/Service/ProductServiceTest.php

# 2. Implement minimum code to pass

# 3. Run test again - should pass
./vendor/bin/pest tests/Unit/Service/ProductServiceTest.php

# 4. Refactor

# 5. Run all tests
./vendor/bin/pest

Code Quality

Before Committing

# Fix code style
./vendor/bin/php-cs-fixer fix

# Run static analysis
./vendor/bin/phpstan analyse

# Run tests
./vendor/bin/pest

# All checks
composer run-script check

Pre-commit Hook

#!/bin/sh
# .git/hooks/pre-commit

./vendor/bin/php-cs-fixer fix --dry-run
if [ $? -ne 0 ]; then
    echo "Fix code style before committing"
    exit 1
fi

./vendor/bin/phpstan analyse
if [ $? -ne 0 ]; then
    echo "Fix PHPStan errors before committing"
    exit 1
fi

API Development

Testing API Endpoints

# Using curl
curl -X GET http://localhost/api/products
curl -X POST http://localhost/api/products \
    -H "Content-Type: application/json" \
    -d '{"name": "Test", "price": 1999}'

# Using httpie (cleaner)
http GET localhost/api/products
http POST localhost/api/products name="Test" price:=1999

API Documentation

# Generate OpenAPI spec
bin/console api:openapi:export --output=openapi.json

# View in browser
# http://localhost/api/docs

End of Day

Clean Up

# Stop services
docker compose down

# Or keep data but stop containers
docker compose stop

Commit Work

# Check status
git status

# Stage changes
git add -p  # Interactive staging

# Commit
git commit -m "feat: add product filtering"

# Push
git push origin feature/product-filtering

Quick Reference

TaskCommand
Clear cachebin/console cache:clear
Run migrationsbin/console doctrine:migrations:migrate
Load fixturesbin/console doctrine:fixtures:load
Run tests./vendor/bin/pest
Fix code style./vendor/bin/php-cs-fixer fix
Static analysis./vendor/bin/phpstan analyse
Debug routesbin/console debug:router
Debug servicesbin/console debug:container
Consume messagesbin/console messenger:consume async