0

I am using a composer's package available at packagist that is https://packagist.org/packages/phpmailer/phpmailer . so my question is that how can we use such composer based packages in Laravel which don't have service providers like Laravel packages have?

I know we can use require autoload file of this package but isn't it bad approach to use require for one package when everything else is autloaded using composer autoload mechanism ? or if I need to conver into Laravel's package first then what are basic steps to do that? Is there any guide available for that purpose?

Hafiz
  • 4,187
  • 12
  • 58
  • 111
  • Just add an entry for phpmailer to the composer.json file for your project – Mark Baker Oct 22 '16 at 23:14
  • @MarkBaker how? Do you mean to give path of PHPMailer in composer autoload array? – Hafiz Oct 22 '16 at 23:41
  • 1
    No, just add it like you would any other composer package: `composer require phpmailer/phpmailer`, then just `$mail = new \PHPMailer\PHPMailer\PHPMailer;` and start using it. No paths or anything odd required, just works using standard autoloader. – Synchro Oct 23 '16 at 08:40
  • @MarkBaker ok, this question was asked a while ago but I know that we can simply require a composer based package and start using it as this package is not based on any Laravel feature. So please add it in answer field so I can mark it solved. Or else I will add answer here for others. – Hafiz Aug 04 '17 at 20:53

0 Answers0