zend-framework2

Issue in Create new Controller in Zend Framework 2 (ZF2)

…衆ロ難τιáo~ 提交于 2019-12-06 11:23:44
I am using ZF2 Skeleton app. To create a new controller in a existing Module, I modified the module.config.php file like this: <?php return array( 'controllers' => array( 'invokables' => array( 'Album\Controller\Album' => 'Album\Controller\AlbumController', // WORKING FINE 'Album\Controller\Photo' => 'Album\Controller\PhotoController', // I ADDED THIS ), ), // The following section Was PREVIOUSLY THERE 'router' => array( 'routes' => array( 'album' => array( 'type' => 'segment', 'options' => array( 'route' => '/album[/:action][/:id]', 'constraints' => array( 'action' => '[a-zA-Z][a-zA-Z0-9_-]*'

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

馋奶兔 提交于 2019-12-06 11:00:49
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/questions/19616982/zf2-file-upload-by-jquery-file-upload-file-was-not-found

Zf3 controller not able to access the model class table located in another module

走远了吗. 提交于 2019-12-06 10:39:19
I am new to Zend Framework. Is there a way to access the model class table which is located in another module from my active controller? As its bye bye service locator in ZF3 i am not able to access the model class table located in other modules. Previously in ZF2 controller private configTable; public function getConfigTable() { if (!$this->configTable) { $sm = $this->getServiceLocator(); $this->configTable = $sm->get('Config\Model\ConfigTable'); // <-- HERE! } return $this->configTable; } public function indexAction(){ $allConfig = $this->getConfigTable()->getAllConfiguration(); ...... } As

ZF2: Equivalent of getServiceLocator in Zend Form

家住魔仙堡 提交于 2019-12-06 10:15:11
问题 assumption: Event\Service\EventService is my personal object that works with Event\Entity\Event entities This code works in an ActionController: $eventService = $this->getServiceLocator()->get('Event\Service\EventService'); How can I get $eventService in a Zend\Form\Form in the same way? 回答1: You have two options if you have a dependency like this. In your case, a Form depends on a Service . The first option is to inject dependencies : class Form { protected $service; public function

PHPExcel in Zend2 Controller

余生颓废 提交于 2019-12-06 08:19:43
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'); And file was allowed to download. How can I achive something similar in Zend2 Controller? I've tried

The hydrator settings are ignored in Apigility

痴心易碎 提交于 2019-12-06 07:59:39
问题 In Apigility it's possible to set a Hydrator for every Entity -- either over the Apigility UI or directly in the module.config.php , e.g.: return array( ... 'zf-hal' => array( 'metadata_map' => array( 'Portfolio\\V2\\Rest\\Project\\ProjectEntity' => array( 'entity_identifier_name' => 'id', 'route_name' => 'portfolio.rest.project', 'route_identifier_name' => 'id', 'hydrator' => 'Zend\\Stdlib\\Hydrator\\ObjectProperty', // 'hydrator' => 'MyNamespace\\Hydrator\\ProjectHydrator', ), ... ), ... ),

ZF2 - multiple nav menus using the navigation view helper

别来无恙 提交于 2019-12-06 07:31:47
问题 I am trying to use a main navigation in combination with a submenu for more specific navigating. In my layout I am calling the view helper like this: $this->navigation('main_navigation')->menu() and in my view I am calling it like this: $this->navigation('sub_navigation')->menu() The problem is that whenever I call the navigation() view helper a more than once , it just outputs the second one in both places. In other words, it's printing the subnav for both the main nav and the subnav menus.

Getting request Authorization header in ZF2 controller

前提是你 提交于 2019-12-06 07:23:08
问题 I am using ZF2 and for some reason, I can get all the headers I send EXCEPT the Authorization header - it's like its filtered out. I am trying to get all the headers in the controller like this: public function createAction($data) { $request = $this->request; print_r ($request->getHeaders()); exit(); } I send the request through cURL like this: curl -i -H "Accept: test" -H "Authorization: 123456" -H "Content-Type: qwerty" -X POST http://localhost/test All headers prints out EXCEPT

Database unit test bound to implementation detail

人走茶凉 提交于 2019-12-06 07:04:40
问题 I have a simple PHP-Class that wraps the access to the database to retrieve a user and want to unit-test it. I currently have the following code: The class to test: class UserTable { protected $tableGateway; public function __construct(\Zend\Db\TableGateway\TableGateway $tableGateway) { $this->tableGateway = $tableGateway; } public function getUserWithId($id) { return $this->tableGateway->select(['id' => $id])->current(); } } The unit test: class UserTableTest extends \PHPUnit_Framework

how to configure doctrine command line tools on zenframework 2

空扰寡人 提交于 2019-12-06 06:36:46
问题 i am using doctrine 2 on zendframework 2. i have configured both correcly and they are both working. i however wish to use doctrine's command line tool to generate entities etc. i have followed doctrine's instructions and created a cli-config.php page in the root of my application: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html i am however lost on two issues; the configuration requires a bootstrap php page ; however, zendframework 2 does not use