zend-framework2

Add caching to Zend\\Form\\Annotation\\AnnotationBuilder

孤人 提交于 2019-12-05 12:12:38
As I've finally found a binary of memcache for PHP 5.4.4 on Windows, I'm speeding up the application I'm currently developing. I've succeeded setting memcache as Doctrine ORM Mapping Cache driver, but I need to fix another leakage: Forms built using annotations. I'm creating forms according to the Annotations section of the docs . Unfortunately, this takes a lot of time, especially when creating multiple forms for a single page. Is it possible to add caching to this process? I've browsed through the code but it seems like the Zend\Form\Annotation\AnnotationBuilder always creates the form by

Parent Child Relationship With A Single Entity In Doctrine 2

假装没事ソ 提交于 2019-12-05 11:28:23
I have database table that looks like this: +----+--------+--------------------+ | id | parent | description | +----+--------+--------------------+ | 1 | null | P Cat 1 | | 2 | 1 | Child 1 of P Cat 1 | | 3 | 1 | Child 2 of P Cat 1 | | 4 | null | P Cat 2 | | 5 | 4 | Child 1 of P Cat 2 | | 6 | 4 | Child 2 of P Cat 2 | +----+--------+--------------------+ How can I create a doctrine 2 entity that has these columns, but I need the parent column to reference the "id" column as a parent. Of course, a parent record has a null "parent" column value. So fair I have <?php namespace MyNamespace; use

zf2 create select/drop down box and populate options in controller?

不羁的心 提交于 2019-12-05 11:24:09
To Create a text input box I used folling code in zend framework2 use Zend\Form\Form; class Loginform extends Form { public function __construct() { $this->add(array( 'name' => 'usernames', 'attributes' => array( 'id' => 'usernames', 'type' => 'text', ), 'options' => array( 'label' => 'User Name', ), )); } } and I can populate the values in controller action using $form = new Loginform(); $form->get('usernames')->setAttribute('value', 'user 1'); Any idea how can I do the same for Selection/drop down box in zf2? Ref: zend framework 2 documentation Daniel M Check the API (the docs are terrible,

How to Render a custom view with plugins in Zend Framework 2

别等时光非礼了梦想. 提交于 2019-12-05 11:01:44
I'm working on an app that needs to send an email after a process is complete. Since the email needs to be HTML I had the bright idea of rendering a view as the email message body so that I can implement a "Click here to see this on your browser" functionality. This is all taking part inside a controller that implements AbstractRestfulController so the view itself resides in my front end module so that it can be accessed from a URL through a browser. However I am getting an No RouteStackInterface instance provided error when I try to render the view. This is my code: use Zend\View

Zend Framework 2 session life time

我只是一个虾纸丫 提交于 2019-12-05 10:24:22
I am trying to set the max life time of a session with the \Zend\Session\Container . To test it I put it to 1 sec. Now I looked at the docs So i did $config = new StandardConfig(); $config->setOptions(array( 'remember_me_seconds' => 1, )); $manager = new SessionManager($config); $session = new Container('user', $manager); But no success. Then I started googling and found this answer So I made the config to return array( 'session' => array( 'remember_me_seconds' => 2419200, 'use_cookies' => true, 'cookie_httponly' => true, ), ); (the config worked and was loaded into the manager) but again no

Zend 2:: getting public folder path or basePath() easily in controller action

心已入冬 提交于 2019-12-05 08:18:01
In my application, to move a file to a specific directory i need to know public folder path in controller action. I read different this type solution but not getting easy one. I know that in view we can get easily public folder path using $this->basePath(); view helper. I exactly want this in controller action. Anybody can guide me how can i achieve that. Thanks in advance. index.php sets the current working dir to you application root (the folder containing composer.json , init_autoloader.php , etc.) As long as you haven't called chdir elsewhere in your application you can call getcwd() and

Zend Framework 2 & jquery modal dialog

南楼画角 提交于 2019-12-05 07:49:28
问题 How does one go about displaying a controller action inside of jquery modal dialog? 回答1: Firstly you'll need your Javascript to load a url via ajax, this will depend on which kind of modal you are using etc, there's a ton of libraries out there. I will assume you are using the basic JQuery UI dialog Modal. Example Link <!-- this points to your action below.. --> <a class="some-link" title="title here" href="mycontroller/test">testing</a> Example Javascript (quick example found on google, many

Set Zend\\Form Error Messages from Controller

自作多情 提交于 2019-12-05 07:43:25
this is probably a very simple task, but currently I'm failing horribly at it. I just want to add a custom error to my form when my authentication fails. What i tried $form->setMessages(array( array('password' => $this->failedLoginMessage) )); Unexpected Result \Zend\Debug\Debug::dump($form->getMessages()); array(0) {} If i understand the code correctly this should attach an error message to the password element. Actually looking at the setMessages i thought attaching a single-dimension array should have been enough, but it needs the 2nd dimension, too :S I'm just stuck on that simple task,

CodeIgniter 2 + Zend 2 library barcode

自古美人都是妖i 提交于 2019-12-05 07:08:41
问题 Problem: rendering barcodes in CodeIgniter via Zend library barcode. I googled, and also tried all tutorials on first 2 pages. I stackoverflowed and found quiet a few topics on my problem, even few are marked as answered but no luck. Finally I tried this https://stackoverflow.com/a/15480779/1564365 but yet another error message. error: Fatal error: Class 'Zend\Barcode\ObjectPluginManager' not found that means it is actually loading Barcode library but with error. sidenote : ZF 2.2 fresh

How can Smarty 3 be Used with Zend Framework 2?

…衆ロ難τιáo~ 提交于 2019-12-05 05:56:16
I used PHP5 a long time ago and am presently trying to refresh my knowledge and augment it with knowledge of Zend Framework 2 and Smarty 3 for a possible project. I'm currently trying to figure out how to use Smarty 3 as a replacement/supplement to Zend Framework 2. Everything I can find through Google on this topic either: Is outdated (e.g. Zend Framework 1) Assumes I have a more intimate working knowledge about both Zend and Smarty than I actually do. Can someone please explain to me as though I were 9 , using the Zend Skeleton Application as my starting point: In what directory/folder