zend-framework2

Best practice to call another controller action from a controller in ZF2

て烟熏妆下的殇ゞ 提交于 2019-12-06 04:23:21
问题 What is the best way of calling an action of another controller? I am thinking in different options: Using forward plugin Setting the second controller as a dependency in the first controller I think the first option will work but I would like to know if the second one has sense. In that case, How can I get the controller dependency? I have tried to get it using the Service Manager but it isn't there. I have tried creating a Factory for the controller and get the another controller from the

ZF2 getServiceLocator() not found?

送分小仙女□ 提交于 2019-12-06 04:22:58
问题 I can't for the life of me get $this->getServiceLocator() to work in my controller. I've read and tried everything. I'm guessing I'm missing something?? Here is some code. namespace Login\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\Session\Container as SessionContainer; use Zend\Session\SessionManager; use Zend\View\Model\ViewModel; use Zend\Mvc\Controller; use Login\Model\UserInfo; class LoginController extends AbstractActionController { private $db; public

Controller specific layout in ZendFramework 2

南笙酒味 提交于 2019-12-06 04:17:50
I have a module in my zendframework 2 application which contains two controllers. I want to set a different layout for one of the controller's actions. Is there a way to set it inside module config file? P.s: I just tried to set it inside controller's __CONSTRUCT method using the following commands but it just didnt worked! $event = $this->getEvent(); $event->getViewModel()->setTemplate('layout/MYLAYOUT'); But if i use the above commands inside each action of my controller it just works fine. See akrabat's examples for a number of nice ways that layouts, views, etcetera can be tweaked easily.

Using ajax in zend framework 2

萝らか妹 提交于 2019-12-06 04:01:27
问题 i am really new to the zend framework 2 and to the programming of web applications. In my application, i want to have a button which triggers a function that changes the content of a database and returns a String which i can use to update the visible content of the website. As i don´t want the website to reload when the button is clicked, i would like to do this using ajax. After reading a couple of ajax tutorials, i imagined that the solution would look somilar to this: The HTML part: <head>

Does Zend Framework 2.0 leave out the amazon s3 library functions that were included in 1.12?

烈酒焚心 提交于 2019-12-06 04:01:13
问题 I was unable to find the equivalent of this http://framework.zend.com/manual/1.12/en/zend.service.amazon.s3.html In the 2.0 version documentation. I also noticed that the 2.0 minimal version is 2.5MB while the 1.12 minimal version is 8.7MB and the full 1.12 version is ~30MB. 回答1: ZF2 doesn't provides a built-in library for S3 or any other AWS services by default. Zend\Service components has been removed from repository as of July 2012 and some of them still maintained under individual

Zend Framework 2 Flash Messenger returning no messages

﹥>﹥吖頭↗ 提交于 2019-12-06 03:47:21
问题 I'm having a rather odd problem with flash messenger in ZF2. I'm using it in quite a simple scenario, save a 'registration complete' message after registering and redirect to the login page and display the message however the messages are never returned by the flash messenger. In controller register action: $this->flashMessenger()->addMessage('Registration complete'); return $this->redirect()->toRoute('default', array('controller' => 'user', 'action' => 'login')); In controller login action:

Doctrine2: [Semantical Error] Cannot select entity through identification variables without choosing at least one root entity alias

谁说胖子不能爱 提交于 2019-12-06 03:40:30
This is my query with query builder, and it works perfectly, bringing all the results of user table and the modules table, which has a many to many association: public function getUser($id){ $qb = $this->getEm()->createQueryBuilder() ->select('u', 'm') ->from('Adm\Entity\User', 'u') ->join('u.modules', 'm') ->where('u.id = ?1') ->setParameters(array(1 => $id)); $result = $qb->getQuery()->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY); return $result; } But when i try to select specific fields from user like this: public function getUser($id){ $qb = $this->getEm()->createQueryBuilder() -

How to use the partial in zendframework2

假装没事ソ 提交于 2019-12-06 03:17:30
问题 In ZF1 we use partial in layout.phtml file something like that $this->partial('header.phtml', array('vr' => 'zf2')); How we can do the same in ZF2? 回答1: this can be achieved by echo $this->partial('layout/header', array('vr' => 'zf2')); you can access the variable in view using echo $this->vr; don't forget to add following line in your view_manager of module.config.php file. 'layout/header' => __DIR__ . '/../view/layout/header.phtml', after adding it looks like this return array( 'view

Zend\Session\SessionManager and cookie_lifetime

雨燕双飞 提交于 2019-12-06 03:14:25
问题 I'm seeing some odd and frustrating behavior with ZF2 sessions and timeouts. Here's the code I use to set up the session: $sessionConfig = new \Zend\Session\Config\StandardConfig(); $sessionConfig->setOptions(array( 'cache_expire' => 525949, 'cookie_domain' => 'mydomain.com', 'cookie_lifetime' => 31536000, 'cookie_path' => '/', 'cookie_secure' => TRUE, 'gc_maxlifetime' => 31536000, 'name' => 'mydomain', 'remember_me_seconds' => 31536000, 'use_cookies' => TRUE, )); $sessionManager = new \Zend

How to install zend framework 2.4.11 skeleton application

牧云@^-^@ 提交于 2019-12-06 03:13:48
问题 I am trying to install ZF 2.4.11 using https://framework.zend.com/manual/2.4/en/ref/installation.html , but after completing the installation, the home page displays ZF version 3.0.2 DEV . How can I correctly install Zend Skeleton Application of desired version (2.4.11) . I am using php 5.6 . 回答1: Execute following: $ git clone https://github.com/zendframework/ZendSkeletonApplication.git zf2 $ cd zf2 $ git checkout origin/release-2.4 You will get a message: HEAD is now at ff7b0e4... Pin to 2