Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram Integration on Laravel 5

I kept getting this issue after installing this package below

https://github.com/vinkla/instagram

into my Laravel 5.1 project.

2018-02-27 at 1 55 36 pm

I followed everything in the instruction.

I am on Mac OS X, PHP 7.1, Laravel 5.1.

Did I forget something?

like image 392
code-8 Avatar asked Feb 04 '23 01:02

code-8


2 Answers

Your report() method is being passed a PHP7 Throwable instead of an Exception.

Laravel 5.1 was not updated to support PHP7 Throwables until 5.1.8.

Considering the error, and the line number specified in HandleExceptions.php, it seems as if you are using a version previous to this (5.1.0 - 5.1.7).

You will need to update Laravel to at least 5.1.8 to fix this error. 5.1.8 was updated to convert Throwables to Symfony\Component\Debug\Exception\FatalThrowableError exceptions, which are then passed to the report() method.

like image 91
patricus Avatar answered Feb 06 '23 14:02

patricus


You could change app\Exceptions\Handler.php to not have the type declaration Exception and handle some logic within it to convert the Error to an Exception. It looks like this is a known issue in laravel 5.2 <= with php 7. https://github.com/laravel/framework/issues/9650

from:

/**
 * Report or log an exception.
 *
 * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
 *
 * @param  \Exception  $exception
 * @return void
 */
public function report(Exception $exception)
{
    parent::report($exception);
}

to:

/**
 * Report or log an exception.
 *
 * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
 *
 * @param  \Exception  $exception
 * @return void
 */
public function report($exception)
{
    if ($exception instanceof Exception) {
        parent::report($exception);
    } else {
       // convert to exception and then parent::report.
    }

}

You will most likely need to do the same thing with the Handler render method.

like image 24
Alex Harris Avatar answered Feb 06 '23 16:02

Alex Harris