zbateson / mail-mime-parser

An email parser written in PHP
https://mail-mime-parser.org/
BSD 2-Clause "Simplified" License
442 stars 56 forks source link

Class not found #143

Closed swilkey closed 3 years ago

swilkey commented 3 years ago

Hi,

I'm trying to use your mailparser as it looks potentially a lot better than the standard php one, but I'm having a problem getting started.

I'm getting "PHP Fatal error: Uncaught Error: Class 'ZBateson\MailMimeParser\MailMimeParser' not found in ..." This is caused by the following line in the code: $mailParser = new \ZBateson\MailMimeParser\MailMimeParser();

I have followed the installation instructions you provided - ie. I ran this "composer require zbateson/mail-mime-parser" in the folder where my php file is running from.

I have these declared at the top of my php: use ZBateson\MailMimeParser\Header\Part\ParameterPart; use ZBateson\MailMimeParser\MailMimeParser; use ZBateson\MailMimeParser\Message; use GuzzleHttp\Psr7;

I honestly don't think I need all of them, but I progressively added them to see if it helped...

I was intrigued that it is declared in the failing line with initialcaps, but in composer.json it is all lowercase, but changing it to lowercase didn't help.

I also followed all the instructions in this paragraph: "MailMimeParser has minimal external dependencies. It requires mbstring to be installed and configured, and two additional composer dependencies that are downloaded and installed via composer: guzzle’s guzzlehttp\psr7 library, and a sister library created to house psr7 stream decorators used by MailMimeParser called zbateson\stream-decorators." however zbateson\stream-decorators - that I don't think is actually needed - causes this error when I try to require it with composer " Could not find a matching version of package zbatesonstream-decorators. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable)."

I do not understand why I am getting the class not found error. I cannot see any evidence of other users having the same problem as I've googled for a similar error but can't find one. Can you please give me any hints?

Thanks, Stephen

zbateson commented 3 years ago

Hi @swilkey --

Unfortunately that is more an issue with composer than it is with mail-mime-parser.

This page should help lots though -- https://getcomposer.org/doc/01-basic-usage.md#autoloading my guess would be you forgot to 'include' the autoloader, but it's hard to say exactly without looking in much more detail if that's not the issue. There's also a composer 'getting started' guide that is very helpful.

All the best, Zaahid

swilkey commented 3 years ago

Thank you! I started exploring possible composer issues last night so I appreciate this advice as I haven't solved it yet

On Tue, Oct 6, 2020, 4:54 AM Zaahid Bateson notifications@github.com wrote:

Hi @swilkey https://github.com/swilkey --

Unfortunately that is more an issue with composer than it is with mail-mime-parser.

This page should help lots though -- https://getcomposer.org/doc/01-basic-usage.md#autoloading my guess would be you forgot to 'include' the autoloader, but it's hard to say exactly without looking in much more detail if that's not the issue. There's also a composer 'getting started' guide that is very helpful.

All the best, Zaahid

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zbateson/mail-mime-parser/issues/143#issuecomment-703790140, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5UXTCEISNELMV5OB5QCZLSJIB5JANCNFSM4SCS64PA .

swilkey commented 3 years ago

Thank you! Yes, it was the missing autoload statement. For some reason, I had made the mistake of concluding that if it was autoloading then it didn't need me to put anything in there, including the autoload statement!

------ Original Message ------ From: "Zaahid Bateson" notifications@github.com To: "zbateson/mail-mime-parser" mail-mime-parser@noreply.github.com Cc: "swilkey" stephen@thewilkeys.net; "Mention" mention@noreply.github.com Sent: 6/10/2020 4:54:28 AM Subject: Re: [zbateson/mail-mime-parser] Class not found (#143)

Hi @swilkey https://github.com/swilkey --

Unfortunately that is more an issue with composer than it is with mail-mime-parser.

This page should help lots though -- https://getcomposer.org/doc/01-basic-usage.md#autoloading my guess would be you forgot to 'include' the autoloader, but it's hard to say exactly without looking in much more detail if that's not the issue. There's also a composer 'getting started' guide that is very helpful.

All the best, Zaahid

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zbateson/mail-mime-parser/issues/143#issuecomment-703790140, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5UXTCEISNELMV5OB5QCZLSJIB5JANCNFSM4SCS64PA.

swilkey commented 3 years ago

Your class works really nicely! thank you