Skip to content

Fw Framework v1.0.4

Choose a tag to compare

@velkymx velkymx released this 24 Feb 04:00
· 102 commits to main since this release
641c294
  • Fixed array response handling: The framework now correctly handles array responses from controllers by converting them to JSON responses with proper headers. Previously, calling setHeader() on the Response object would fail because the method doesn't exist.
  • Fixed json_encode() on Model instances producing wrong output: Model now implements \JsonSerializable, delegating to toArray(). Previously, passing a model directly to json_encode() would silently serialize internal object state instead of the model's attributes, with no warning. Collection was already correctly implemented.

Changed Methods

  • RequestFiber.php:233: Changed $this->app->response->setHeader('Content-Type', 'application/json') to $this->app->response->header('Content-Type', 'application/json')
  • Component.php:315: Changed $this->app->response->setHeader('Content-Type', 'application/json') to $this->app->response->header('Content-Type', 'application/json')
  • Component.php:326: Changed $this->app->response->setHeader('Location', $url) to $this->app->response->header('Location', $url')
  • src/Model/Model.php: Added implements \JsonSerializable to the class declaration and added jsonSerialize(): array method that delegates to toArray()

Impact

  • Controllers returning arrays will now work correctly
  • JSON responses will have proper Content-Type headers
  • Redirect functionality in components will work properly
  • No breaking changes - maintains backward compatibility

Migration

No migration steps required. This is a bug fix that improves existing functionality.

Notes

This release fixes a critical bug that prevented array responses from working correctly in API controllers. The framework now properly handles array responses by converting them to JSON with appropriate headers.