Laravel usage

In order to use JsonMapper with your Laravel application you only need JsonMapper’s LaravelPackage.

The installation of JsonMapper Laravel package can easily be done with Composer

$ composer require json-mapper/laravel-package

The example shown above assumes that composer is on your $PATH.

Now JsonMapper will be automatically injected if it is provided as one of the constructor arguments.

<?php

namespace App\Service;

use JsonMapper\JsonMapper;

class ApiClient
{
    /** @var JsonMapper */
    private $mapper;
    
    public function __construct(JsonMapper $mapper)
    {
        $this->mapper = $mapper;
    }
}