Search code examples
laraveltwiliotwilio-php

Laravel Artisan Optimize Issue


I have an odd situation happening when I use Laravel's php optimize functionality.

$goodRequest = $requestValidator->validate($request->header('X-Twilio-Signature'), $request->fullUrl(), $requestData);

if(App::environment('prod')) {
    // Debuggin Information
    Log::info($request->header('X-Twilio-Signature'));
    Log::info(config("app.TWILIO_AUTH_TOKEN"));
    Log::info($request->fullUrl());
    Log::info(implode(" ", $requestData));
    Log::info($goodRequest);
}

When I don't optimize, the $goodRequest variables get set correctly, however when I do optimize the application, $goodRequest becomes null.

Here is the sample output

[2021-08-21 10:25:25] prod.INFO: ABCDEFGHIJKLMNOP=
[2021-08-21 10:25:25] prod.INFO: 4328fsdh34820hfdj02384902fskj
[2021-08-21 10:25:25] prod.INFO: http://example.com/api
[2021-08-21 10:25:25] prod.INFO: US MA SMfc505a8dd5fbf47a87f62a565dae808f 0 BOSTON 11111 SMfc505a8dd5fbf47a87f62a565dae808f MA received BOSTON TEXT MA +111111111 11111 1 SMfc505a8dd5fbf47a87f62a565dae808f AC6236758eb7752b014afdf2f249d4121e +1111111111 2010-04-01
[2021-08-21 10:25:25] prod.INFO:

The last debug statement prints out the $goodRequest value and nothing gets set. Any thoughts?


Solution

  • Twilio developer evangelist here.

    I'm not a Laravel developer, but is this because Laravel's logger doesn't show anything when you log a boolean? Could you try:

    Log::info($goodRequest ? "true" : "false");