- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
67 lines
2.7 KiB
PHP
67 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Attributes\Route;
|
|
use App\Framework\Http\Method;
|
|
use App\Framework\Router\ValueObjects\Placeholder;
|
|
use App\Framework\Router\ValueObjects\RoutePath;
|
|
|
|
echo "=== Testing Route Value Objects ===\n\n";
|
|
|
|
// Test 1: Traditional string route
|
|
echo "1. Traditional string route:\n";
|
|
$stringRoute = new Route(path: '/api/users/{id}', method: Method::GET);
|
|
echo " Path: " . $stringRoute->getPathAsString() . "\n";
|
|
echo " Dynamic: " . ($stringRoute->getRoutePath()->isDynamic() ? 'Yes' : 'No') . "\n";
|
|
echo " Parameters: " . implode(', ', $stringRoute->getRoutePath()->getParameterNames()) . "\n\n";
|
|
|
|
// Test 2: Value Object route - your original example
|
|
echo "2. Value Object route (your example):\n";
|
|
$routePath = RoutePath::fromElements('images', Placeholder::fromString('filename'));
|
|
$valueObjectRoute = new Route(path: $routePath, method: Method::GET);
|
|
echo " Path: " . $valueObjectRoute->getPathAsString() . "\n";
|
|
echo " Dynamic: " . ($valueObjectRoute->getRoutePath()->isDynamic() ? 'Yes' : 'No') . "\n";
|
|
echo " Parameters: " . implode(', ', $valueObjectRoute->getRoutePath()->getParameterNames()) . "\n\n";
|
|
|
|
// Test 3: Complex Value Object route
|
|
echo "3. Complex Value Object route:\n";
|
|
$complexPath = RoutePath::fromElements(
|
|
'api',
|
|
'users',
|
|
Placeholder::typed('userId', 'uuid'),
|
|
'posts',
|
|
Placeholder::typed('postId', 'int')
|
|
);
|
|
$complexRoute = new Route(path: $complexPath, method: Method::POST);
|
|
echo " Path: " . $complexRoute->getPathAsString() . "\n";
|
|
echo " Parameters: " . implode(', ', $complexRoute->getRoutePath()->getParameterNames()) . "\n\n";
|
|
|
|
// Test 4: Fluent builder
|
|
echo "4. Fluent builder approach:\n";
|
|
$fluentPath = RoutePath::create()
|
|
->segment('api')
|
|
->segment('files')
|
|
->typedParameter('filename', 'filename')
|
|
->build();
|
|
$fluentRoute = new Route(path: $fluentPath);
|
|
echo " Path: " . $fluentRoute->getPathAsString() . "\n";
|
|
|
|
// Test 5: Wildcard
|
|
echo "\n5. Wildcard route:\n";
|
|
$wildcardPath = RoutePath::fromElements('files', Placeholder::wildcard('path'));
|
|
$wildcardRoute = new Route(path: $wildcardPath);
|
|
echo " Path: " . $wildcardRoute->getPathAsString() . "\n";
|
|
echo " Regex: " . $wildcardRoute->getRoutePath()->toRegex() . "\n";
|
|
|
|
// Test 6: Compatibility check
|
|
echo "\n6. Compatibility check:\n";
|
|
$stringRoute2 = new Route(path: '/api/users/{id}');
|
|
$objectRoute2 = new Route(path: RoutePath::fromElements('api', 'users', Placeholder::fromString('id')));
|
|
echo " String and object routes are equivalent: " .
|
|
($stringRoute2->getPathAsString() === $objectRoute2->getPathAsString() ? 'Yes' : 'No') . "\n";
|
|
|
|
echo "\n=== All tests completed successfully! ===\n";
|