zend-framework2

Doctrine Inheritance replacement

那年仲夏 提交于 2019-12-04 05:42:37
Currenty we're developing a very flexible and modular application with Zend Framework 2 and Doctrine 2. In this application there are multiple Doctrine entities, for example let's say the entity Product in the module Products . This module Products is the base/default module for product management. We want to be able to create a custom Products module for a customer ( XProducts ). Therefore I created a new entity, XProduct (with some extra fields) which extends Product . So if the custom module is enabled I want to use XProduct and else Product , but never together (in the same project). If I

ZF2 SessionManager usage

纵饮孤独 提交于 2019-12-04 05:38:19
I am new to ZF2 and not quite used to how to do stuff. I want to use session to keep track of an user (remember me). I had this code in one part of my class: $sessionManager = new \Zend\Session\SessionManager(); $sessionManager->rememberMe($time); // i want to keep track of my user id too $populateStorage = array('user_id' => $user->getId()); $storage = new ArrayStorage($populateStorage); $sessionManager->setStorage($storage); Ok, so far so good. When i try: var_dump($sessionManager->getStorage()); I get the expected data. In another part of my program, i want to retreive my data again (a bit

Executing multiple join with expressions on Zend Framework 2

牧云@^-^@ 提交于 2019-12-04 04:25:43
Actually I'm working on a project and I'm looking on how Zend Framework 2 handle complex queries (expecially on how to join n:m tables and how to use GROUP_CONCAT and other functions). Do you know the best practice to execute this query: SELECT o. * , x.group_one, x.group_two FROM table_one AS o LEFT JOIN ( SELECT r.fk1, GROUP_CONCAT( t.field_one ) AS group_one, GROUP_CONCAT( t.field_two ) AS group_two FROM table_three AS r INNER JOIN table_two AS t ON r.fk2 = t.id GROUP BY r.fk1 ) AS x ON o.id = x.fk1 LIMIT 0 , 20; using this db schema: -- -- Database: `table-test-1` -- -- -------------------

Inserting NULL into NOT NULL columns with Default Value

試著忘記壹切 提交于 2019-12-04 04:02:30
For a bit of background, we use Zend Framework 2 and Doctrine at work. Doctrine will always insert NULL for values we do not populate ourselves. Usually this is okay as if the field has a default value, then it SHOULD populate the field with this default value. For one of our servers running MySQL 5.6.16 a query such as the one below runs and executes fine. Although NULL is being inserted into a field which is not nullable, MySQL populates the field with its default value on insert. On another of our servers running MySQL 5.6.20 , we run the query below and it falls over because it complains

Zf2 - How to set cookie

你说的曾经没有我的故事 提交于 2019-12-04 03:29:22
I found this topic Zend Framework 2 - Cookie Concept while I was searching for info about setting cookie in ZF2, but seems like information included in that topic are out of date. I have tried following code: public function indexAction() { $request = $this->getRequest()->getHeaders()->get('Set-Cookie')->foo = 'bar; $response = $this->getResponse()->getCookie()->baz = 'test'; var_dump($_COOKIE); ... return new ViewModel(); } Both lines output warning: Warning: Creating default object from empty value I tried also: public function indexAction() { $cookie = new SetCookie('test', 'value', 60*60

Disable notInArray Validator Zend Framework 2

若如初见. 提交于 2019-12-04 03:13:37
Is there a way to disable notInArray Validator in Zend Framework 2. All the info on the internet shows how to disable the notInArray Validator in Zend Framework 1, for example in this fashion If you do not want the InArray validator at all, you can disable this behavior by either calling setRegisterInArrayValidator(false) on the element, or by passing false to the registerInArrayValidator configuration key on element creation. One the posts in stackoverflow can be found here Unfortunately this is not possible in Zend Framework 2. So in case if anybody has a tip how this can be disabled. Since

Zend Framework 2 SOAP AutoDiscover and complex types

与世无争的帅哥 提交于 2019-12-04 03:12:20
I'm preparing the SOAP server and generating my WSDL using the follow code: //(... Controller action code ...) if (key_exists('wsdl', $params)) { $autodiscover = new AutoDiscover(); $autodiscover->setClass('WebServiceClass') ->setUri('http://server/webserver/uri'); $autodiscover->handle(); } else { $server = new Server(null); $server->setUri($ws_url); $server->setObject($this->getServiceLocator()->get('MyController\Service\WebServiceClass')); $server->handle(); } //(... Controller action code ...) But in one of my WebService method I have a parameter of type Array in which each element is of

Routing in Zend Framework 2

亡梦爱人 提交于 2019-12-04 03:09:55
问题 I'm trying to do some routing in Zend Framework 2, but it's not working. The basics of the skeleton application are working, so I added a new module called User and the following code in the file \module\User\config\module.config.php 'controllers' => array( 'invokables' => array( 'User\Controller\User' => 'User\Controller\UserController', ), ), 'router' => array( 'routes' => array( 'login' => array( 'type' => 'Literal', 'options' => array( 'route' => '/login', 'defaults' => array( '_

How do I turn on the PHP error reporting in Zend Framework 2?

不打扰是莪最后的温柔 提交于 2019-12-04 02:41:38
Everytime I receive an error in Zend Framework 2, I get just 500 Internal Server Error displayed and have to search through the Zend Server error log. I've tried putting this to my config/autoload/local.php file but it doesn't work: return array( 'phpSettings' => array( 'display_startup_errors' => true, 'display_errors' => true, ), ); There is no native support for that in zf2 (afaik). You'd either have to set them in php.ini itself, or set them in index.php <?php error_reporting(E_ALL); ini_set('display_errors', true); If you really want to be able to supply them as config settings, you could

ZF2 - Generating Url from route

做~自己de王妃 提交于 2019-12-04 02:40:29
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' => array ( 'route' => '/Indexqvm[/:action][/:id_event]', 'constraints' => array ( 'action' => '[a-zA-Z][a