laravel-validated-dto icon indicating copy to clipboard operation
laravel-validated-dto copied to clipboard

Exception: Serialization of 'Closure' is not allowed

Open patriziotomato opened this issue 9 months ago • 4 comments

If you need to serialize an DTO, or an object where an DTO is embedded, you will get a

Exception: Serialization of 'Closure' is not allowed

as Validation logic contains Closures, that cannot get serialized.

patriziotomato avatar Feb 10 '25 18:02 patriziotomato

Proposal to fix it: https://github.com/WendellAdriel/laravel-validated-dto/pull/101

patriziotomato avatar Feb 10 '25 18:02 patriziotomato

Hey @patriziotomato Thanks a lot, I'll check the PR

WendellAdriel avatar Feb 11 '25 11:02 WendellAdriel

Any idea why I get this, while using make test ?

   FAILED  Tests\Unit\ValidatedDTOTest > it validates that ValidatedDTO can be instantiated with file validation rules                                                                               LogicException   
  GD extension is not installed.

patriziotomato avatar Feb 12 '25 08:02 patriziotomato

Hey @patriziotomato That's weird, I didn't face this before. But you can try adding this to the Dockerfile, although I'm not 100% sure this is still the correct way of installing the extension on the PHP Alpine image 😅

# Install system dependencies
RUN apk add --no-cache --update \
    curl \
    openssl \
    libpng-dev \
    libjpeg-turbo-dev \
    freetype-dev \
    libzip-dev \
    unzip

# Install the GD extension 
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && docker-php-ext-install gd

If it doesn't work, let me know

WendellAdriel avatar Feb 12 '25 10:02 WendellAdriel

This fix was released on v4.2.1

WendellAdriel avatar Jun 19 '25 14:06 WendellAdriel