# Quick Start Guide

Get your Custom PHP Framework deployed quickly with this step-by-step guide.

## Project Information
- **Domain**: michaelschiemer.de
- **Email**: kontakt@michaelschiemer.de
- **PHP Version**: 8.4
- **Framework**: Custom PHP Framework

## Prerequisites

- Linux/macOS/WSL environment
- Internet connection
- Sudo privileges (for dependency installation)

## 1. First-Time Setup

Run the setup script to install dependencies and configure the deployment environment:

```bash
cd deployment/
./setup.sh
```

This will:
- Install Docker, Docker Compose, and Ansible
- Create configuration files from templates
- Generate SSH keys for deployment
- Validate the environment

### Non-Interactive Setup

For automated/CI environments:

```bash
./setup.sh --skip-prompts
```

## 2. Configure Your Environments

Edit the environment files created during setup:

```bash
# Development environment
nano applications/environments/.env.development

# Staging environment  
nano applications/environments/.env.staging

# Production environment
nano applications/environments/.env.production
```

**Important**: Replace all template values, especially:
- Database passwords
- SSL email addresses
- API keys and secrets

## 3. Test Your Configuration

Validate your configuration without making changes:

```bash
# Using the deploy script
./deploy.sh staging --dry-run

# Using make commands
make deploy-dry ENV=staging
make validate-config ENV=staging
```

## 4. Deploy to Staging

Deploy to staging environment for testing:

```bash
# Using the deploy script
./deploy.sh staging

# Using make command
make deploy-staging
```

## 5. Deploy to Production

When ready for production:

```bash
# Test production deployment first
./deploy.sh production --dry-run

# Deploy to production (requires confirmation)
./deploy.sh production

# Or using make
make deploy-production
```

## Quick Commands Reference

### Main Deployment Commands

```bash
# Deploy full stack to staging
make deploy-staging

# Deploy full stack to production
make deploy-production

# Dry run for any environment
make deploy-dry ENV=production

# Deploy only infrastructure
make infrastructure ENV=staging

# Deploy only application
make application ENV=staging
```

### Status and Health Checks

```bash
# Check deployment status
make status ENV=staging

# Run health checks
make health ENV=production

# View application logs
make logs ENV=staging
```

### Configuration Management

```bash
# Show deployment info
make info

# Validate configuration
make validate-config ENV=production

# Edit configuration
make edit-config ENV=staging
```

### Emergency Commands

```bash
# Emergency stop all services
make emergency-stop ENV=staging

# Emergency restart all services
make emergency-restart ENV=production

# Create backup
make backup ENV=production
```

## Deployment Flow

1. **Validation**: Prerequisites, configuration, and tests
2. **Infrastructure**: Ansible deploys security, Docker, Nginx, SSL
3. **Application**: Docker Compose deploys PHP app, database, assets
4. **Health Checks**: Validates deployment success

## Safety Features

- Production deployments require double confirmation
- Database backups are created automatically
- Dry run mode for testing without changes
- Health checks verify deployment success
- Emergency stop/restart commands available

## Next Steps

- Review [Environment Configuration](ENVIRONMENTS.md) for detailed setup
- Check [Troubleshooting Guide](TROUBLESHOOTING.md) if issues arise
- Customize Ansible playbooks for your specific needs
- Set up monitoring and alerting for production

## Support

For issues or questions:
- Check the troubleshooting guide
- Review deployment logs
- Verify configuration files
- Test with dry-run mode first

Happy deploying! 🚀