Composer? Namespace? How to config use Mailin package?

Trying to use https://github.com/mailin-api/mailin-api-php

See attachments, showing installed files and IDE highlighting for namespace.

phpStorm is trying to tell me something? The USE statement is grey but the actual usage (new) is not an error in the IDE.

But runtime error is Class ‘SendinBlue\Mailin’ not found

I am just guessing at a config:


        // SendinBlue

        'mailin' => [

            'class' => 'mailin-api\Sendinblue\Mailer',

            //'class'=>'vendor/mailin-api/mailin-api-php/src/Sendinblue/Mailin.php',

            //'class'=>'Sendinblue\Mailin'

        ],



… help! I do not have the Yii2/composer smarts to know where to look next…

Thank you

I just saw, mailin is not a Yii2 extension.

Your schould look at Working with Third-Party Code

You can easy use every code that is compatible with composer in you yii2 project.

It does not have to be yii2 extension.

As I can see you have already install it to vendor folder.

But php autoloading is CASE SENSETIVE.

And you should use correct namespace in ‘use’ declaration - https://github.com/mailin-api/mailin-api-php/blob/master/composer.json (pay attention to ‘autoload’ declaration).

This should work (just change ‘SendinBlue’ to ‘Sendinblue’):





use Sendinblue\Mailin;


...

// somewhere in controller action

$mailin = new Mailin("https://api.sendinblue.com/v2.0","your access key");




@ mikezimin Perfect! Thank you so much.