I have a Laravel 10 app running on php 8.2. Now i am facing difficulties with an api call in production. Just to clarify: the api works fine, it is one specific route causing problems.
This is the code from the API Controller:
public function indexContact(): JsonResponse
{
return response()->json([
'captcha' => Captcha::create('math', true),
'categories' => ContactController::CATEGORIES,
]);
}
Captcha is imported with use Mews\Captcha\Facades\Captcha;
from the mews/captcha package.
Now i get a Sentry issue saying Undefined property: Intervention\Image\EncodedImage::$encoded
, which is thrown in the call stack of Captcha::create
. The breadcrumbs say, that before the App thew the Error, the captcha got written into cache.
I tried making the API Call to the server myself and received an 500 Internal Server Error.
But when i boot up my local environment, which is on the same git version and run the API request there, it succeeds witout Issue. I have checked and compared package versions and code and both localhost ond production have the same composer lock entry. There are no Errors when deploying. I am thankful for any help.
If local and remote environment are absolutely identical I suggest you to clear laravel caches (specifically route caches) by running
php artisan optimize
php artisan config:cache
php artisan config:clear
Also double-check php extensions, enabled php version, and installed packages
composer show -i
php -i
And try to update/rollback Intervention\Image, this issue is encountered by other people too, guess due to Intervention\Image recent updates