小编Moh*_*ibi的帖子

如何为控制台命令创建侦听器

我想在运行每个控制台命令时运行一个方法,如何为流明中的所有控制台命令创建一个监听器?

我尝试创建一个侦听器ConsoleCommandEvent,此事件被触发\Symfony\Component\Console\Application::doRunCommand,但事件调度程序尚未附加(请阅读方法上方的注释: 如果事件调度程序已附加到应用程序,则事件也会在生命周期中调度命令.)

更新使用此事件:Illuminate\Console\Events\ArtisanStarting可能有助于完成工作,但这是一个不同的事件.通过这样做,php artisan无论您是否运行实际命令,都将执行您运行代码的任何时间.

php console laravel lumen

9
推荐指数
1
解决办法
900
查看次数

在ZF2中发送带有附件的电子邮件

如何在zf2中发送带有text/plain,text/html和attach的电子邮件?我使用此代码发送带有smtp的电子邮件:

$files = $this->params()->fromFiles();
$smtp = new \Zend\Mail\Transport\Smtp();
$smtp->setAutoDisconnect(true);
$optn = new \Zend\Mail\Transport\SmtpOptions(array(
    'host'              => 'mail.myserver.com',
    'connection_class'  => 'login',
    'connection_config' => array(
        'username' => 'user@myserver.com',
        'password' => 'mypassword',
    ),
));
$smtp->setOptions($optn);


$htmlPart = new \Zend\Mime\Part('<p>some html</p>');
$htmlPart->type = Mime::TYPE_HTML;

$textPart = new \Zend\Mime\Part('some text');
$textPart->type = Mime::TYPE_TEXT;

$i=0;
$attaches = array();
foreach($files as $file){
    if ($file['error'])
        continue;
    $attaches[$i] = new \Zend\Mime\Part(file_get_contents($file['tmp_name']));
    $attaches[$i]->type = $file['type'].'; name="'.$file['name'].'"';
    $attaches[$i]->encoding = 'base64';
    $attaches[$i]->disposition = 'attachment';
    $attaches[$i]->filename = $file['name'];
    $i++;
}

$parts = array();
if …
Run Code Online (Sandbox Code Playgroud)

php email-attachments zend-framework2

7
推荐指数
1
解决办法
1万
查看次数

如何在zend framework2中禁用inArray验证器表单

我在我的表格中使用这个:

$this->add(array(     
    'type' => 'Zend\Form\Element\Select',       
    'name' => 'county',
    'registerInArrayValidator' => false,
    'attributes' =>  array(
        'id' => 'county',                
        'options' => array(
            //'null'=>'[Select county]',
        ),
    ),
    'options' => array(
        'label' => 'county',
    ),
));
Run Code Online (Sandbox Code Playgroud)

并使用js设置值县字段.验证后,我收到错误:haystack选项是必需的

forms validation zend-framework2

4
推荐指数
1
解决办法
6080
查看次数

无法连接到主机,某些请求后出现 SoapFault 异常

我正在连接到网络服务以获取一些数据。我有一个包含大约 20 万个作业的请求队列,并且有一个工作人员正在处理它。处理时间为每秒 2-3 次调用。大约 500-1000 次调用后,它开始收到 SoapFault 异常并显示以下消息:Could not connect to host。即使出现此错误,我也能够正确 ping Web 服务服务器。

当我禁用肥皂缓存时,问题仍然存在,但错误更改为Parsing WSDL: Couldn't load from 'http://thewebservice.com/method/Service.asmx?WSDL' : failed to load external entity

连接代码:

$client = new SoapClient('http://thewebservice.com/method/Service.asmx?WSDL');
$response = $client->__soapCall('method name', $parameters)
Run Code Online (Sandbox Code Playgroud)

我与:

  • PHP 7.0.11
  • 流明 (5.2.9)(Laravel 组件 5.2.*)

php soap soap-client laravel lumen

3
推荐指数
1
解决办法
3228
查看次数