Releases: bearsunday/BEAR.Resource
1.29.0
1.28.0
Added
- Ray.InputQuery
#[Input]attribute support for OPTIONS method- OPTIONS requests now properly expand
#[Input]parameters to show constructor properties - Added comprehensive test coverage for Input parameter expansion scenarios
- OPTIONS requests now properly expand
Fixed
- Bug where non-Input required parameters were dropped when
#[Input]attribute existed - OPTIONS method now correctly handles mixed Input and regular parameters
Changed
- Refactored
OptionsMethodRequestparameter processing for improved maintainability- Extracted Input parameter processing to dedicated method
- Improved code organization and readability
1.27.0
Changes
Changed
- PHP 8 Attributes Migration: Removed
doctrine/annotationsanddoctrine/cachedependencies, migrated to native PHP 8 attributes - Minimum PHP Version: Updated requirement from PHP 8.1 to PHP 8.2
- Development Tools: Updated PHPUnit from 9.6 to 11.0, migrated test suite to PHP 8 attributes
- Dependencies: Updated to stable Ray dependencies (ray/aop ^2.18.0, ray/di ^2.18.0), replaced nocarrier/hal with koriym/hal ^1.1
- CI/CD: Updated Scrutinizer CI to PHP 8.4
Removed
doctrine/annotations(abandoned package)doctrine/cache(abandoned package)symfony/polyfill-php83(unnecessary for PHP 8.2+)- Backward compatibility code for annotations
Fixed
- CI workflow to remove PHP 8.1 from test matrix
- Parameter processing to handle methods without attributes correctly
- Updated
.gitignorefor.phpunit.cachedirectory
⚠️ Migration Required
Applications using annotations must migrate to PHP 8 attributes:
composer require --dev bearsunday/rector-bearsunday
# Preview changes
vendor/bin/rector process src --config=vendor/bearsunday/rector-bearsunday/rector.php --dry-run
# Apply migration
vendor/bin/rector process src --config=vendor/bearsunday/rector-bearsunday/rector.phpWhy This Change?
The doctrine/annotations package has been officially abandoned by its maintainers. This change:
- Eliminates security and compatibility risks from abandoned packages
- Adopts native PHP 8 attributes as the modern standard
- Improves performance (no runtime annotation parsing overhead)
- Provides automated migration tooling
Full changelog: https://github.com/bearsunday/BEAR.Resource/blob/1.x/CHANGELOG.md
1.26.3
1.26.2
Changed
- Updated
ray/input-querydependency to version ^0.3.0
This minor release updates the Ray.InputQuery dependency to support the latest features and improvements in version 0.3.0.
For full changelog, see: https://github.com/bearsunday/BEAR.Resource/blob/1.x/CHANGELOG.md
1.26.1
What's Changed
Fixed
- Exception handling in parameter resolution: Fixed issue where
InvalidArgumentExceptionfrom Ray.InputQuery was not properly caught and converted toParameterException, causing unhandled exceptions when empty queries were passed to resource methods. - Consistent exception hierarchy: Maintains BEAR.Resource's exception hierarchy by converting Ray.InputQuery exceptions to framework-specific exceptions.
- Proper exception chaining: Preserves original exception context for better debugging.
This patch release ensures that the Ray.InputQuery integration introduced in 1.26.0 properly handles parameter validation errors in a way that's consistent with the framework's exception handling patterns.
Technical Details
When Ray.InputQuery integration was added in 1.26.0, it introduced InvalidArgumentException for missing parameters, but NamedParameter was not catching these exceptions. This caused unhandled exceptions to bubble up when empty queries were passed to various methods that previously caught ParameterException.
The fix properly catches InvalidArgumentException from Ray.InputQuery and converts it to ParameterException to maintain backward compatibility and consistent error handling throughout the framework.
Full Changelog: 1.26.0...1.26.1
What's Changed
Full Changelog: 1.26.0...1.26.1
1.26.0
🌟 World's First HTML Form ↔ PHP Method Perfect Mapping
BEAR.Resource 1.26.0 introduces a groundbreaking paradigm that creates perfect 1:1 mapping between HTML forms and PHP method signatures - the first of its kind in web development history!
🎯 The Revolutionary Innovation
Perfect HTML ↔ PHP Symmetry
<\!-- Your HTML Form -->
<form enctype="multipart/form-data">
<input name="name" value="John Doe" required>
<input name="email" type="email" value="[email protected]" required>
<input name="avatar" type="file" accept="image/*">
<input name="documents[]" type="file" multiple accept=".pdf">
</form>// PHP Constructor (Perfect Mirror\!)
final class UserRegistration
{
public function __construct(
#[Input] string $name,
#[Input] string $email,
#[InputFile(allowedTypes: ['image/jpeg', 'image/png'])]
?FileUpload $avatar = null,
#[InputFile(allowedExtensions: ['pdf'])]
array $documents = []
) {}
}This is not just similar - it's IDENTICAL structure! 🤯
🔥 Revolutionary Features
1. Flat Query → Hierarchical Objects
// HTTP Request: ?name=John&addressStreet=123&addressCity=Tokyo
// Automatically becomes:
final class UserInput {
public function __construct(
#[Input] public readonly string $name,
#[Input] public readonly AddressInput $address // Nested object\!
) {}
}
$user = $inputQuery->newInstance(UserInput::class, $_GET);
echo $user->address->street; // "123" - Perfect hierarchy\!Key Innovation: addressStreet and addressCity automatically compose the AddressInput object.
2. Input Classes as First-Class Citizens
Unlike DTOs or Entities, Input classes are dedicated to representing input structure:
final class CheckoutInput {
public function __construct(
#[Input] public readonly CartInput $cart,
#[Input] public readonly ShippingAddressInput $shipping,
#[Input] public readonly PaymentMethodInput $payment,
#[Input] public readonly ?string $couponCode = null
) {}
}This IS your checkout form structure - not an approximation!
3. Zero Boilerplate File Uploads
// BEAR.Resource magic - just define the structure
public function onPost(UserRegistrationInput $input): static
{
// $input->avatar is already a validated FileUpload object
// $input->documents is already an array of FileUpload objects
return $this->userService->register($input);
}
// Testing is trivial
$mockAvatar = FileUpload::fromFile(__DIR__ . '/fixtures/avatar.jpg');
$input = new UserRegistrationInput(
name: 'Test User',
email: '[email protected]',
avatar: $mockAvatar,
documents: []
);4. Type Safety from Edge to Edge
[Type-Safe Zone ←→ Type-Safe Zone ←→ Type-Safe Zone]
HTML Form Input Classes Domain Objects
No more "type-less void" between your form and your business logic!
🎊 What Makes This Revolutionary
World's First: HTML-Native Object Mapping
- GraphQL: Requires special query language
- Traditional Frameworks: Manual form processing
- BEAR.Resource 1.26.0: Native HTML forms become PHP objects automatically
Input-First Architecture
// Traditional: "How to parse this data?"
$title = $_POST['title'] ?? '';
if (empty($title)) throw new ValidationException('Title required');
// Ray.InputQuery: "What should this data be?"
final class TodoInput {
public function __construct(
#[Input] public readonly string $title, // Validation implicit
#[Input] public readonly AuthorInput $author
) {}
}Declarative Form Processing
Instead of writing parsing code, you declare the structure. The framework handles the rest.
AI-Ready Architecture
Clear, structured inputs make AI code generation natural:
- HTML Form → Auto-generate Input classes
- Input classes → Auto-generate validation
- Perfect documentation through type signatures
🚀 Technical Breakthroughs
Ray.InputQuery Integration
- Seamless integration for form data processing
- Support for
AbstractFileUploadreturn types inInputFormParamandInputFormsParam - Automatic nested object creation from flat parameters
Enhanced Type System
- Comprehensive type definitions in
Types.phpfor bulletproof type safety - Strong typing throughout the entire request pipeline
- Value objects for domain-specific types (Email, UserId, etc.)
File Upload Revolution
// Production: Automatic file processing
$input = $inputQuery->newInstance(UserProfileInput::class, $_POST);
// Testing: Simple mock injection
$input = new UserProfileInput(
name: 'Test',
avatar: FileUpload::fromFile('test.jpg')
);Three-Way Harmony (Future Vision)
Input Classes (PHP)
/ \
/ \
HTML Forms JSON Schema
(Interface) (Contract)
All three representations of the same structure!
📈 Performance Philosophy
Validation Pyramid Inversion
Traditional: Validation Everywhere (Expensive)
┌─────────────────┐
│ Controller │ ← Validate
├─────────────────┤
│ Service │ ← Validate again
├─────────────────┤
│ Repository │ ← Validate again
└─────────────────┘
Input-First: Validation Once (Efficient)
┌─────────────────┐
│ Input Boundary │ ← ALL validation here
├─────────────────┤
│ Controller │ ← Trust
├─────────────────┤
│ Service │ ← Trust
├─────────────────┤
│ Repository │ ← Trust
└─────────────────┘
Result: Validate once at the boundary, trust everywhere else.
🎯 Real-World Impact
For Frontend Developers
- Form structure directly maps to backend types
- Clear contracts between frontend and backend
- Instant feedback on structure changes
For Backend Developers
- No more manual form parsing
- Type-safe request handling
- Focus on business logic, not data wrangling
For DevOps/Testing
- Predictable data flow
- Easy mock generation
- Clear error boundaries
For AI Development
- Structured, parseable code
- Clear input/output contracts
- Natural code generation targets
🔧 Enhanced Dependencies
- ray/input-query: ^0.2.0 - Core flat→hierarchical transformation
- koriym/file-upload: ^0.2.0 - Type-safe file upload handling
- ext-fileinfo: * - Cross-platform file type detection
🏆 Paradigm Shift Summary
This isn't just an update - it's a fundamental advancement in web development:
- Perfect Symmetry: HTML structure = PHP structure
- Zero Translation: No manual parsing layer needed
- Type Safety: From HTTP request to domain objects
- Declarative Design: Define structure, not processing
- AI-Ready: Clear, structured, parseable code
🌟 The Future is Input-First
BEAR.Resource 1.26.0 represents the evolution from:
- "How do I process this form?" → "What is this form's structure?"
- Imperative parsing → Declarative structure
- Manual validation → Structural constraints
This is not just a library update - it's the future of web application development! 🚀
Full Changelog: 1.25.0...1.26.0
Join the Input-First revolution and experience the future of web development today!
1.25.0
A handler interface has been created that is called when the validation of the schema specified in JsonSchema is not enabled when entering a request.
public function handleRequestException(
array $arguments,
ResourceObject $ro,
JsonSchemaException $e,
string $schemaFile,
)What's Changed
- Add request exception handler for JSON schema validation by @koriym in #315
- Pass arguments to JsonSchemaRequestExceptionHandlerInterface by @NaokiTsuchiya in #316
Full Changelog: 1.24.0...1.25.0
