dougu3290 2017-12-09 18:19
浏览 75

将外部库添加到Phalcon项目中

Cannot add the Phalcon mailer and use it in the project. Doing same as instructions say. I have config linking to 'libraryDir' => APP_PATH . '/app/lib/', in the lib folder I have a Mailer folder where I put the composer.json.

I followed THIS but after using the lib in the Controller I've got

Fatal error: Uncaught Error: Class 'Phalcon\Ext\Mailer\Manager'

Code :

use Phalcon\Http\Response; 
use Phalcon\Mvc\Model\Criteria; 
use Phalcon\Mvc\Model\Query\BuilderInterface; 
use Phalcon\Di\InjectionAwareInterface; 
use Phalcon\Mvc\Model\Resultset; use Phalcon\Ext\Mailer\Manager; 
use Phalcon\Ext\Mailer\Message;

class EmailController extends Phalcon\Mvc\Controller { 
public function initialize() { 
if ($this->request->isPost()) { 
$this->view->disable(); 
} 
}
public function indexAction() {

}

public function sendEmailAction(){
    if ($this->request->isPost()) {

        $config = [
            'driver'   => 'mail',
            'from'         => [
                'email' => 'manager@email.com',
                'name'    => 'Email'
            ]
        ];

        $email = new Phalcon\Ext\Mailer\Message($config);
        return "send";
    }
}
}
  • 写回答

2条回答 默认 最新

  • douzhao1912 2017-12-09 19:22
    关注

    You have to follow Phalcon\Ext\Mailer installation instructions. There is no instructions about putting somewhere composer.json. Just install this library using typical for the Composer way:

    composer require "phalcon-ext/mailer":"~2.0"
    

    The last thing you need: make sure that you are using Composer autoloader:

    require_once 'vendor/autoload.php';
    
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?