Zend Framework

A solid unit test suite is essential for ongoing development in large projects, especially those with many people involved. Going back and manually testing every individual component of an application after every change is impractical. Your unit tests will help alleviate that by automatically testing your application’s components and alerting you when something is not working the same way it was when you wrote your tests. The Zend Framework 2 API uses PHPUnit, and so does this tutorial application. A detailed explanation of unit testing is beyond the scope of this tutorial, so we will only provide sample tests for the components in the pages that follow. This tutorial assumes that you already have PHPUnit installed.
In this article, you will learn how to create a custom view helper in Zend Framework 2. A concrete example will be used; a helper which generates links for a subdomain, intended for storing static files. This is especially useful if you wish to use a Content Delivery Network (CDN). With very little modification, the helper can be made generic to support links to subdomains for all purposes. The Helper Class Let us begin by creating the helper class. It can be added within any module, but a suitable place would be within the Application module, provided that you made use of the Skeleton Application. Create a file CdnHelper.php in zf2-tutorial\module\Application with the following subdirectories:
Yesterday, I spent several hours solving this problem. In Laravel Framework, you can do as following: Mail::send("mails.reset", $data, function ($message) use ($email) { $message ->from("noreply@infinitescript.com", "CourseOcean") ->subject("Reset Your Password"); $message->to($email); }); Step 1: Create an Email Template First of all, you need to create an email template in the views folder, such as /view/mails/reset.phtml. <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td style=" padding: 15px 15px 0 15px; background: #fff; border-radius: 4px 4px 0 0; " > <div> <img src="http://lab.haozhexie.com/CourseOcean/img/logo.png" alt="CourseOcean" height="85" width="290" /> </div> </td> </tr> <tr> <td style=" padding: 15px; background: #fff; border-radius: 0 0 4px 4px; font-size: 12px; " > We received a request to reset the password for your account, <?=$this->username?>.<br /><br /> If you made this request, click the link below. If you didn't make this request, you can ignore this email.<br /><br /> <a href="http://lab.haozhexie.com/CourseOcean/accounts/resetPassword?email=<?=$this->email?>&amp;keycode=<?=$this->keycode?>" target="_blank" style="color: #005399; text-decoration: none" >http://lab.haozhexie.com/CourseOcean/accounts/resetPassword?email=<?=$this->email?>&amp;keycode=<?=$this->keycode?></a ><br /><br /> Yours, <br /> CourseOcean.<br /><br /> <div style=" border-top: 3px solid #eee; color: #999; font-size: 11px; line-height: 1.2; " > <br />Powered by <a href="http://lab.haozhexie.com/CourseOcean/" target="_blank" style="color: #005399; text-decoration: none" >CourseOcean</a >. All rights reserved.<br /> </div> </td> </tr> </tbody> </table> Step 2: Complete Sending Email Function function sendResetPasswordEmail($username, $email) { $keycode = $this->generateRandomString(32); $view = new \Zend\View\Renderer\PhpRenderer(); $resolver = new \Zend\View\Resolver\TemplateMapResolver(); $resolver->setMap([ "mailTemplate" => __DIR__ . "/../../../view/mails/reset.phtml", ]); $view->setResolver($resolver); $viewModel = new ViewModel(); $viewModel->setTemplate("mailTemplate")->setVariables([ "username" => $username, "email" => $email, "keycode" => $keycode, ]); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($view->render($viewModel)); $bodyMessage->type = "text/html"; $bodyPart->setParts([$bodyMessage]); $message = new \Zend\Mail\Message(); $message ->addFrom("noreply@infinitescript.com", "CourseOcean") ->addTo($email) ->setSubject("Reset Your Password") ->setBody($bodyPart) ->setEncoding("UTF-8"); $transport = new \Zend\Mail\Transport\Sendmail(); $transport->send($message); }

Course Ocean

Introduction CourseOcean is aimed at serving as a training platform for IT skills, where anyone can create a course and anyone can find a suitable course for themselves. Code Repository GitLab Screenshots
The easiest way to do that would be to use the Params plugin, introduced in beta5. It has utility methods to make it easy to access different types of parameters. As always, reading the tests can prove valuable to understand how something is supposed to be used. Get a single value To get the value of a named parameter in a controller, you will need to select the appropriate method for the type of parameter you are looking for and pass in the name.
I’ve been getting into trouble for several hours with redirecting to the 404 page in Zend Framework 2. The question in StackOverflow: http://stackoverflow.com/questions/21622849/use-the-same-error-handler-in-different-modules-in-zend-framework-2 Before that, I’m using the following code: $this->getResponse()->setStatusCode(404); return; It works fine. However, after I create the 404 error page. I found it won’t redirect you to the error page with the code above. If you want to redirect to the 404 error page, you should use the following code: