zend-framework2

Make zend framework 2 work without Virtual Host

末鹿安然 提交于 2019-12-08 03:46:29
问题 I had finished my first web application using Zend Framework 2 and I'm about to put it online. But may web host doesn't allow me to change my vhost configuration! The .htaccess file is allowed. My .htaccess file in Public folder is like this: RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it. RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] #

'Row count is not available in unbuffered result sets.' with Zend Table Gateway

主宰稳场 提交于 2019-12-08 03:38:02
问题 I'm trying to use Zend TableGateway as a stand alone component with my app (not ZF2). Below is a simple test script to just fetch some rows but I get the error Uncaught exception 'Zend\Db\Adapter\Exception\RuntimeException' with message 'Row count is not available in unbuffered result sets.' in /var/www/shared-views-slim/vendor/zendframework/zend-db/Zend/Db/Adapter/Driver/Mysqli/Result.php:324 Below is my code: /** * This makes our life easier when dealing with paths. Everything is relative *

Difference between InputFilterAwareInterface and InputFilterProviderInterface in ZF2

邮差的信 提交于 2019-12-08 03:37:33
Can someone explain me the difference between both interfaces InputFilterAwareInterface and InputFilterProviderInterface? Both seem to serve to the same purpose, to get an InputFilter, but I know they cannot be the same... And when do they get called? Thanks edigu Both interfaces exist for different purposes. The InputFilterAwareInterface guarantees that implemented classes will have a setInputFilter() and getInputFilter() methods which accept and return an InputFilter instance when necessary. On the other hand, the InputFilterProviderInterface guarantees only that implemented classes will

Difference between InputFilterAwareInterface and InputFilterProviderInterface in ZF2

元气小坏坏 提交于 2019-12-08 03:12:03
问题 Can someone explain me the difference between both interfaces InputFilterAwareInterface and InputFilterProviderInterface? Both seem to serve to the same purpose, to get an InputFilter, but I know they cannot be the same... And when do they get called? Thanks 回答1: Both interfaces exist for different purposes. The InputFilterAwareInterface guarantees that implemented classes will have a setInputFilter() and getInputFilter() methods which accept and return an InputFilter instance when necessary.

ZF2 register custom helper for navigation

橙三吉。 提交于 2019-12-08 02:29:44
问题 I am using Zend Navigation with ACL . My users can have multiple roles, which have no relation to each other, but Zend Navigation only accepts one role and checks the ACL with that role which is not good for me. How can I register a new Helper for the Navigation such that I can override the acceptAcl method. I tried to create and register a simple view helper but that didn't work class Menu extends \Zend\View\Helper\Navigation\Menu implements \Zend\ServiceManager\ServiceLocatorAwareInterface

How to set query parameter with redirect()

試著忘記壹切 提交于 2019-12-08 02:01:58
问题 I would like to set a query parameter when redirecting. I tried this: $this->redirect()->toRoute('login/default', array('action' => 'forgotPassword', 'foo' => 'bar')); It redirects to: /login/forgotPassword Instead of where I would like to redirect which is: /login/forgotPassword?foo=bar 回答1: The query parameter belongs to the third parameter of the URL-Methods. $this->redirect()->toRoute( 'login/default', array( 'action' => 'forgotPassword' ), array( 'query' => array( 'foo' => 'bar' )) ) 回答2

Access config global in Zend Framework 2

南楼画角 提交于 2019-12-08 02:01:14
问题 I would like to access to my global configs ( config/{,*.}{global,local}.php ) located in my personal libraries (in the vendor directory). But despite my search in the web, I did not succeed to achieve this. I know how to access the config file of a module : \MyModule\Module::getConfig() I know how to access the global configurations from a controller : $this->getServiceLocator()->get('config'); But how to access these from a file inside the vendor directory ? My libraries do not extend

Zf2 file upload by jQuery File Upload - file was not found

最后都变了- 提交于 2019-12-08 01:56:40
问题 when I use jQuery File Upload I have error during ajax upload. In controller: $adapter = new \Zend\File\Transfer\Adapter\Http(); $adapter->isValid(); or $adapter->receive(); Both methotds returns "File [file name] was not found" dump from $_FILES: Array ( [files] => Array ( [name] => Penguins.jpg [type] => image/jpeg [tmp_name] => /tmp/phpwQoG2L [error] => 0 [size] => 777835 ) ) If I use move_uploaded_file in the same place all works ZF2 v2.2.4 What is wrong? 来源: https://stackoverflow.com

Controller specific layout in ZendFramework 2

坚强是说给别人听的谎言 提交于 2019-12-08 01:31:56
问题 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.

PHPExcel in Zend2 Controller

落花浮王杯 提交于 2019-12-08 00:25:38
问题 I'm trying to get PHPExcel working with Zend2. Actually it is working, but not as I intended (I can write to file, but cannot let download without saving). I found some examples, where you simply do something like this: $objPHPExcel = .... header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="01simple.xls"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output');