Fw Framework v1.0.4
- 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:Modelnow implements\JsonSerializable, delegating totoArray(). Previously, passing a model directly tojson_encode()would silently serialize internal object state instead of the model's attributes, with no warning.Collectionwas 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: Addedimplements \JsonSerializableto the class declaration and addedjsonSerialize(): arraymethod that delegates totoArray()
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.