Search code examples
jsonserializer

laravel Interface 'JsonSerializable' not found


Im using the following for my application for social media login https://github.com/madewithlove/laravel-oauth2

but im getting this error

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Interface 'JsonSerializable' not found
open: /Applications/AMPPS/www/docsearch/vendor/madewithlove/laravel-oauth2/src/OAuth2/Token/Access.php
 * @package    OAuth2
 * @category   Token
 * @author     Phil Sturgeon
 * @copyright  (c) 2011 HappyNinjas Ltd
 */

class Token_Access extends Token implements \JsonSerializable
{
    /**
     * @var  string  access_token

Solution

  • This isn't actually a Laravel issue, it's to do with your version of PHP. If you look at the official PHP documentation you'll see that this particular interface is only available for PHP versions 5.4 and up.

    Source: http://php.net/manual/en/class.jsonserializable.php