Yii Framework Forum: How To Create A New Component - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Create A New Component

#1 User is offline   Dong Nguyen Huu 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 06-December 13

Posted 31 January 2014 - 12:16 PM

Hi,
I'm implementing a component for sending emails through Mandrill. These are my steps :
1. add "mandrill/mandrill": "dev-master" to composer.json
2. run php composer.phar update --prefer-dist
3. Create a file in created folder by composer. In this case is vendor/mandrill/mandrill/MandrillMailer.php. And declare the namespace of this class is mandrill
4. change the class of the 'mail' config in main.php


But when I call \Yii::$app->mail, it show error :

Quote

PHP Fatal Error – yii\base\ErrorException

Class 'mandrill\MandrillMailer' not found



Any Ideas what I'm wrong ??


Thanks,
0

#2 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 756
  • Joined: 02-February 09

Posted 31 January 2014 - 04:36 PM

Can you try declaring namespace as mandrill\mandrill
0

#3 User is offline   Dong Nguyen Huu 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 06-December 13

Posted 31 January 2014 - 07:29 PM

View Postbettor, on 31 January 2014 - 04:36 PM, said:

Can you try declaring namespace as mandrill\mandrill


Thanks for reply, but I tried this too, not working . Any ideas else ?
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,596
  • Joined: 17-January 09
  • Location:Russia

Posted 31 January 2014 - 09:16 PM

Check your vendor/yiisoft/extensions.php.
0

#5 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,596
  • Joined: 17-January 09
  • Location:Russia

Posted 31 January 2014 - 09:17 PM

I guess you need to add the following to composer.json:

"autoload": {
	"psr-4": {
		"mandrill\\mandrill\\": ""
	}
}

0

#6 User is offline   Dong Nguyen Huu 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 06-December 13

Posted 31 January 2014 - 10:18 PM

View Postsamdark, on 31 January 2014 - 09:17 PM, said:

I guess you need to add the following to composer.json:

"autoload": {
	"psr-4": {
		"mandrill\\mandrill\\": ""
	}
}




Thanks so much, I've fixed this.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users