spatie / laravel-newsletter

Manage Mailcoach and MailChimp newsletters in Laravel
https://freek.dev/440-easily-integrate-mailchimp-in-laravel-5
MIT License
1.61k stars 235 forks source link

Error: Class 'Spatie\Newsletter\Facades\Newsletter' not found #294

Closed hebertlima closed 1 year ago

hebertlima commented 1 year ago

I was not able to use the lib following the steps described in the documentation, there are some problems that I would like to report:

First, it is not possible to publish the config file with the command:

php artisan vendor:publish --tag="newsletter-config"

image

so i created the file manually...

there seems to be something wrong with this class: 'Spatie\Newsletter\Facades\Newsletter'

use Spatie\Newsletter\Facades\Newsletter;

class WelcomeController {
   public function store($req) {
    Newsletter::subscribe('rincewind@discworld.com'); # <- throw error;
   # Error: Class 'Spatie\Newsletter\Facades\Newsletter' not found
  }
}

this way work:

use Spatie\Newsletter\NewsletterFacade as Newsletter; 

class WelcomeController {
   public function store($req) {
    Newsletter::subscribe('rincewind@discworld.com');
  }
}

I also got the following error:

TypeError: Return value of Spatie\Newsletter\NewsletterList::getId() must be of the type string, null returned

with this envs:

NEWSLETTER_API_KEY=
NEWSLETTER_LIST_ID=
NEWSLETTER_ENDPOINT=

this work:

MAILCHIMP_APIKEY=
NEWSLETTER_LIST_ID=
NEWSLETTER_ENDPOINT=

version:

"laravel/framework": "^8.75",
"drewm/mailchimp-api": "^2.5",
"spatie/laravel-newsletter": "^4.11",
spatie-bot commented 1 year ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.