Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions steering_docs/php-tech/basics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# PHP Interactive Scenario Generation

## MANDATORY: Knowledge Base Consultation (FIRST STEP)
**🚨 CRITICAL - Must be completed BEFORE any code generation**

```bash
# Step 1: List available knowledge bases
ListKnowledgeBases()

# Step 2: Query coding standards (REQUIRED)
QueryKnowledgeBases("coding-standards-KB", "PHP-code-example-standards")

# Step 3: Query implementation patterns (REQUIRED)
QueryKnowledgeBases("PHP-premium-KB", "PHP implementation patterns structure")

# Step 4: AWS service research (REQUIRED)
search_documentation("What is [AWS Service] and what are its key API operations?")
read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]")
```

**FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE**

## Purpose
Generate interactive scenarios that demonstrate complete workflows using multiple service operations in a guided, educational manner. Implementation must be based on the service SPECIFICATION.md file.

## Requirements
- **Specification-Driven**: MUST read the `scenarios/basics/{service}/SPECIFICATION.md`
- **Interactive**: Use `testable_readline()` for user input and clear output
- **Educational**: Break complex workflows into logical phases
- **Comprehensive**: Cover setup, demonstration, examination, and cleanup
- **Error Handling**: Graceful error handling with user-friendly messages
- **Service Classes**: MUST use service wrapper classes for all operations
- **Runner Pattern**: MUST implement interactive Runner.php pattern

## File Structure
```
example_code/{service}/
├── Runner.php # Interactive menu runner
├── {Service}Service.php # Service wrapper class
├── composer.json
├── README.md
└── tests/
├── {Service}Test.php
└── phpunit.xml
```## MA
NDATORY Pre-Implementation Steps

### Step 1: Read Service Specification
**CRITICAL**: Always read `scenarios/basics/{service}/SPECIFICATION.md` first to understand:
- **API Actions Used**: Exact operations to implement
- **Proposed Example Structure**: Setup, demonstration, examination, cleanup phases
- **Error Handling**: Specific error codes and handling requirements
- **Scenario Flow**: Step-by-step workflow description

### Step 2: Extract Implementation Requirements
From the specification, identify:
- **Setup Phase**: What resources need to be created/configured
- **Demonstration Phase**: What operations to demonstrate
- **Examination Phase**: What data to display and how to filter/analyze
- **Cleanup Phase**: What resources to clean up and user options

## Runner Pattern Structure
**MANDATORY for most services:**

```php
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

require 'vendor/autoload.php';

use {Service}\{Service}Service;

echo "Welcome to the {AWS Service} examples!\n";
echo "Choose an option:\n";
echo "1. Hello {Service}\n";
echo "2. Run {Service} Basics Scenario\n";
echo "3. List {Resources}\n";
echo "4. Create {Resource}\n";
echo "5. Delete {Resource}\n";
echo "0. Exit\n";

$choice = testable_readline("Enter your choice: ");

switch ($choice) {
case '1':
require 'Hello{Service}.php';
break;
case '2':
$service = new {Service}Service();
runBasicsScenario($service);
break;
case '3':
$service = new {Service}Service();
$service->list{Resources}();
break;
case '4':
$service = new {Service}Service();
$resourceName = testable_readline("Enter resource name: ");
$service->create{Resource}($resourceName);
break;
case '5':
$service = new {Service}Service();
$resourceId = testable_readline("Enter resource ID: ");
$service->delete{Resource}($resourceId);
break;
case '0':
echo "Goodbye!\n";
break;
default:
echo "Invalid choice\n";
}
```

## Scenario Phase Structure (Based on Specification)

### Setup Phase
- **Read specification Setup section** for exact requirements
- Check for existing resources as specified
- Create necessary resources using service methods
- Configure service settings per specification
- Verify setup completion as described

### Demonstration Phase
- **Follow specification Demonstration section** exactly
- Perform core service operations using service methods
- Generate sample data if specified in the specification
- Show service capabilities as outlined
- Provide educational context from specification

### Examination Phase
- **Implement specification Examination section** requirements
- List and examine results using service methods
- Filter and analyze data as specified
- Display detailed information per specification format
- Allow user interaction as described in specification

### Cleanup Phase
- **Follow specification Cleanup section** guidance
- Offer cleanup options with warnings from specification
- Handle cleanup errors gracefully using service methods
- Provide alternative management options as specified
- Confirm completion per specification

## User Interaction Patterns

### Input Handling
```php
// Yes/No questions
$useExisting = testable_readline("Use existing resource? (y/n): ");
$isYes = strtolower($useExisting) === 'y';

// Text input
$resourceName = testable_readline("Enter resource name: ");

// Numeric input with validation
do {
$count = testable_readline("How many items? ");
} while (!is_numeric($count) || $count < 1);
```

### Information Display
```php
// Progress indicators
echo "✓ Operation completed successfully\n";
echo "⚠ Warning message\n";
echo "✗ Error occurred\n";

// Formatted output
echo str_repeat('-', 60) . "\n";
echo "Found " . count($items) . " items:\n";
foreach ($items as $item) {
echo " • {$item['name']}\n";
}
```

## Runner Requirements
- ✅ **ALWAYS** read and implement based on `scenarios/basics/{service}/SPECIFICATION.md`
- ✅ **ALWAYS** provide interactive menu for multiple examples
- ✅ **ALWAYS** include hello scenario as first option
- ✅ **ALWAYS** handle user input gracefully using `testable_readline()`
- ✅ **ALWAYS** include proper error handling
- ✅ **ALWAYS** provide clear output and feedback
- ✅ **ALWAYS** use service wrapper classes for all AWS operations
- ✅ **ALWAYS** implement proper cleanup in finally block
- ✅ **ALWAYS** break scenario into logical phases per specification
- ✅ **ALWAYS** include error handling per specification's Errors section
- ✅ **ALWAYS** provide educational context and explanations from specification
96 changes: 96 additions & 0 deletions steering_docs/php-tech/hello.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# PHP Hello Examples Generation

## MANDATORY: Knowledge Base Consultation (FIRST STEP)
**🚨 CRITICAL - Must be completed BEFORE any code generation**

```bash
# Step 1: List available knowledge bases
ListKnowledgeBases()

# Step 2: Query coding standards (REQUIRED)
QueryKnowledgeBases("coding-standards-KB", "PHP-code-example-standards")

# Step 3: Query implementation patterns (REQUIRED)
QueryKnowledgeBases("PHP-premium-KB", "PHP implementation patterns")

# Step 4: AWS service research (REQUIRED)
search_documentation("What is [AWS Service] and what are its key API operations?")
read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]")
```

**FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE**

## Purpose
Generate simple "Hello" examples that demonstrate basic service connectivity and the most fundamental operation using direct AWS SDK for PHP client calls.

## Requirements
- **MANDATORY**: Every AWS service MUST include a "Hello" scenario
- **Simplicity**: Should be the most basic, minimal example possible
- **Standalone**: Must work independently of other examples
- **Direct Client**: Use AWS SDK for PHP client directly, no wrapper classes needed

## File Structure
```
example_code/{service}/
├── Hello{Service}.php # Hello example file
```

## Hello Scenario File Pattern
**MANDATORY standalone hello file:**

```php
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

require 'vendor/autoload.php';

use Aws\{Service}\{Service}Client;
use Aws\Exception\AwsException;

echo "Hello {AWS Service}!\n";

try {
$client = new {Service}Client([
'region' => 'us-east-1',
'version' => 'latest'
]);

// Simple service operation
$result = $client->someBasicOperation();
echo "Successfully connected to {AWS Service}\n";
// Display basic result

} catch (AwsException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
```

## Hello Examples by Service Type

### List-Based Services (S3, DynamoDB, etc.)
- **Operation**: List primary resources (buckets, tables, etc.)
- **Message**: Show count and names of resources

### Status-Based Services (GuardDuty, Config, etc.)
- **Operation**: Check service status or list detectors/configurations
- **Message**: Show service availability and basic status

### Compute Services (EC2, Lambda, etc.)
- **Operation**: List instances/functions or describe regions
- **Message**: Show available resources or regions

## Validation Requirements
- ✅ **Must run without errors** (with proper credentials)
- ✅ **Must handle credential issues gracefully**
- ✅ **Must display meaningful output**
- ✅ **Must use direct AWS SDK for PHP client calls**
- ✅ **Must include proper copyright header**

## Common Patterns
- Always use `new {Service}Client()` directly
- Include comprehensive error handling with try-catch blocks
- Provide user-friendly output messages using echo
- Handle both service-specific and general exceptions
- Keep it as simple as possible - no additional classes or complexity
- Use appropriate AWS SDK for PHP v3 patterns
Loading
Loading