How to integrate a package from Packagist into Laravel 5?

I am working with laravel 5 and trying to integrate the following package: ExactTarget / Fuel-SDK-PHP

I completed my project:

composer require exacttarget/fuel-sdk-php

      

So, I had an exact supplier supplier supplier.

First of all I noticed that this particular package does not use namespaces, so it still calls for directives, but not "use \ path \ namespace". Is this the correct approach? I haven't seen many packages yet, but among my past experiences, I don't find it the right approach to write a package ...

After that, I edit condif / app.php to use the ET_Client class.

 'providers' => [
 ...
 'ET_Client',
 ...

      

],

As soon as I did that, I got an error: it looks like Laravel frmwk is trying to instantiate a class that needs some parameters, even if I'm not using it yet (istantition). Is this normal behavior from Laravel?

Did I miss something?

+3


source to share


1 answer


The array providers

is for registering service provider classes. If it ET_Client

doesn't extend the Laravels base class ServiceProvider

, it won't work.

Instead, just add instructions use

to your PHP classes for how and when you need to use the class:



<?php

namespace App\Http\Controllers;

use ET_Client;

class SomeController extends Controller
{
    public function someAction()
    {
        // Instantiate client class
        $client = new ET_Client;

        // Now do something with it...
    }
}

      

+2


source







All Articles