3

I just wanted to install this class from Pear:

http://pear.php.net/package/Mail_mimeDecode/

After this command:

sudo pear install Mail_mimeDecode-1.5.5

I have this:

downloading Mail_mimeDecode-1.5.5.tgz ...
Starting to download Mail_mimeDecode-1.5.5.tgz (11,554 bytes)
.....done: 11,554 bytes
downloading Mail_Mime-1.8.9.tgz ...
Starting to download Mail_Mime-1.8.9.tgz (33,796 bytes)
...done: 33,796 bytes
install ok: channel://pear.php.net/Mail_Mime-1.8.9
install ok: channel://pear.php.net/Mail_mimeDecode-1.5.5

So everything looks fine. But when i want to use this class i got this error:

Class 'Mail_mimeDecode' not found

I try use it like this ($xml is a string with an XML inside):

$mime = new \Mail_mimeDecode($xml);

I also don't see it in my phpinfo Profiler. Am I missing something ? I work on Symfony2 Application if that changes anything...

Michal Olszowski
  • 795
  • 1
  • 8
  • 25
  • Are you requiring it in your code? – James Spence Apr 15 '15 at 14:17
  • I'm doing it like this: "new \Mail_mimeDecode($xml)". $xml is a string like it should be. – Michal Olszowski Apr 15 '15 at 14:18
  • 1
    My point is, are you __requiring/including__ it? Where in your code are you saying, "load this file that contains this class"? – James Spence Apr 15 '15 at 14:19
  • Shouldn't it work like another classes, like Datetime ? I have no idea how I should use it properly than. I'm installing first time something from pear o.O – Michal Olszowski Apr 15 '15 at 14:21
  • 1
    DateTime is a native PHP class: it's included in PHP itself. What you're doing is downloading a PHP class with PEAR. Your PHP environment has no idea that class exists, because you haven't told it that it does. You need to either include the class in some way like this: `include_once('/path/to/Mail_mimeDecode.php');`, or add it via an autoloader such as composer. Reference [here](https://gist.github.com/whatthejeff/5114513) – James Spence Apr 15 '15 at 14:26
  • See [this question on including classes](http://stackoverflow.com/questions/1994666/php-how-to-include-a-class) to know how to include – James Spence Apr 15 '15 at 14:28
  • I'm doing it right now, I will write back after I will check it out :-) Thanks for help :-) I don't want to include it, i will install it with composer from packagist to my Symfony2 Application. It's quite a big project so I cant just include it xD – Michal Olszowski Apr 15 '15 at 14:33
  • It's working with composer.phar with no problems. I'm feeling so stupid right now, jesus :-) I work in PHP from like 7 years and I just didn't thought this way in this case. Shame on me ... Thanks man :-) – Michal Olszowski Apr 15 '15 at 14:39

1 Answers1

3

You have to configure you PHP include path correctly. Check the PEAR installation section in the manual.

cweiske
  • 30,033
  • 14
  • 133
  • 194