zend-framework2

ZF2 - Generating Url from route

心不动则不痛 提交于 2020-01-01 08:56:32
问题 I can't figure out to generate Url from everywhere i want to, in zend 2 I get action and controller so i try this: $this->url('myControllerName', array('action' => 'myActionName')); But this return an object, i just want the full URL string of this route Somebody can help me to find the proper way? EDIT : according to Stoyan, maybe i made a mistake on my route. here is the part of my module.config 'router' => array ( 'routes' => array ( 'indexqvm' => array ( 'type' => 'segment', 'options' =>

Fatal error: Class 'Locale' not found with ZF2 beta5 skeleton application

谁说胖子不能爱 提交于 2020-01-01 07:56:07
问题 I've just installed the ZF2 beta5 application as per given instructions: $ git clone git://github.com/zendframework/ZendSkeletonApplication.git ./ Cloning into '.'... remote: Counting objects: 1494, done. remote: Compressing objects: 100% (660/660), done. remote: Total 1494 (delta 681), reused 1373 (delta 581) Receiving objects: 100% (1494/1494), 397.42 KiB | 357 KiB/s, done. Resolving deltas: 100% (681/681), done. $ php composer.phar install Installing dependencies - Installing zendframework

how to use ajax in zend framework 2 or the AjaxContext?

无人久伴 提交于 2020-01-01 07:15:09
问题 AjaxContext helper was a neat feature in ZF1 and i used it in many places. I was wondering if this is available in ZF2. I did a test and added: public function init() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('input', 'html') ->addActionContext('number', 'html') ->initContext(); } in the controller, added a action: public function inputAction() { $form = new AddInput(); return ['form' => $form]; } a file input.ajax.phtml and a ajax call: $.get('

How to use the cache in doctrine 2 and zend framework 2?

房东的猫 提交于 2020-01-01 06:43:48
问题 plz i need some help here , i've goolged a lot but without result :/ how can i exploit the query and their result stored in the memcache , i'm working with zend framework 2 and doctrine 2 ? and here is my configuration in module.config.php : // Doctrine config 'doctrine' => array( 'driver' => array( __NAMESPACE__ . '_driver' => array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') ), 'orm_default' => array(

Injecting the Service Manager to Build a Doctrine Repository in ZF2

∥☆過路亽.° 提交于 2020-01-01 03:49:10
问题 How do I inject the service manager into a Doctrine repository to allow me to retrieve the Doctrine Entity Manager? I using the ZF2-Commons DoctrineORMModule and are trying to implement the repository example listed in the Doctrine Tutorial (bottom of tutorial in link below): http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html However, I keep getting a message " Fatal error: Call to a member function get() on a non-object in C:\zendProject\zf2 ... "

How to create form inputs/elements in ZF2

霸气de小男生 提交于 2020-01-01 02:33:07
问题 EDIT : My main question has now become 'How do I get the ServiceManager with the doctrine entity manager into the hands of my form, element, and input classes in some clean way?' Read on to see the full post. I'm going to try and ask by example here so bear with me. Let me know where I'm going wrong/right or where I could improve I'm trying to create a registration form. I could use ZfcUser module but I want to do this on my own. I'm using ZF2 with Doctrine2 as well so that leads me away from

ZF2 how to get entity Manager from outside of controller

蹲街弑〆低调 提交于 2019-12-31 17:56:06
问题 we can access entity manager within controller using $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); but how can we access entity manager singleton instance in rest of the project in Zendframework 2. 回答1: The 'right' way to do it is use a factory to inject the entity manager into any classes that need it. Classes, other than factories, shouldn't really be aware of the ServiceLocator. So, your module config would look like this: 'controllers' => array( 'factories' =>

How to disable render view in zend framework 2?

99封情书 提交于 2019-12-31 08:08:03
问题 I want to use some ajax, but I don't know how to use function as the same as setNoRender() in zend framework 2 to disable for render view. How to disable rendering view in zend framework 2? 回答1: To disable your view : public function myactionAction() { // your code here ... return false; } "return false" disables the view and not the layout! why? because the accepted types are: ViewModel array null so "false" disable the view. To disable layout and view, return a response object: public

How to disable render view in zend framework 2?

故事扮演 提交于 2019-12-31 08:07:29
问题 I want to use some ajax, but I don't know how to use function as the same as setNoRender() in zend framework 2 to disable for render view. How to disable rendering view in zend framework 2? 回答1: To disable your view : public function myactionAction() { // your code here ... return false; } "return false" disables the view and not the layout! why? because the accepted types are: ViewModel array null so "false" disable the view. To disable layout and view, return a response object: public

access controller action variables to zf2 layout

左心房为你撑大大i 提交于 2019-12-31 03:57:09
问题 I have created two layouts: one for the login page and another for the rest of the site. After login I want to pass variables from login controller to zf2 layout, but not able to access. How can i access the variables in layout created in a controller action? 回答1: Some ways to do that in your controller: Using view model $viewmodel = new ViewModel(); $viewmodel->setVariable('myvar', $myvar); return $viewmodel; Using layout() $this->layout()->myvar = $myvar; Into your view script <?php echo