zend-framework2

How to add custom view helpers to Zend Framework 2 (beta 4)

半城伤御伤魂 提交于 2019-12-12 03:47:25
问题 NOTE: This is an old question and the answers here no longer works (since beta5). See this question on how to do it with ZF2 stable version. I have looked at this example from the manual. Note that this is version 2 of the Zend Framework. I create this helper: <?php namespace Mats\Helper; use Zend\View\Helper\AbstractHelper; class SpecialPurpose extends AbstractHelper { protected $count = 0; public function __invoke() { $this->count++; $output = sprintf("I have seen 'The Jerk' %d time(s).",

ZF2 form element description

こ雲淡風輕ζ 提交于 2019-12-12 03:47:10
问题 in ZF1 form and form elements had a setDescription method that was outputted as <p>description here</p> in view .... ZF2 seems that doesn't have this method so my question is how can i add description to form elements ? this is my view : <div> <? $form = $this->form; $form->prepare(); echo $this->form()->openTag($form); foreach ($form->getElements() as $el) { ?> <div class="form_element"> <?=$this->formRow($el);?> </div> <? } echo $this->partial('system/form/buttons_form_part.phtml', array(

Composer not installing dependencies of Package

别来无恙 提交于 2019-12-12 03:40:39
问题 I have two projects. One is my application and the second one is an external module that I want to use in future apps. I have created my external module on GitHub and included in the composer.json of my application. My external module gets downloaded / cloned but the required dependencies are not installed by composer . Here's composer.json of my application: { "name": "application", "description": "Skeleton Application for ZF2", "license": "BSD-3-Clause", "keywords": [ "framework", "zf2" ],

use zend framework 2/3 component's outside zf app

[亡魂溺海] 提交于 2019-12-12 03:39:57
问题 I am trying to use some zend framework components outside of zend framework but I am unable to do so. Here is my composer file. { "require": { "zendframework/zend-authentication": "^2.5.3" }, "autoload": { "psr-4": { "Zend\\Authentication\\": "" } } } I was able to run composer update and install which has generated the autoload.php. But when I try to use a the component I get "Fatal error: Class 'Zend\Authentication\Storage\Session' not found" $session = new \Zend\Authentication\Storage

Doctrine Deployment on test-environment without console-access

◇◆丶佛笑我妖孽 提交于 2019-12-12 03:39:25
问题 I developed an application with Zend Framework and Doctrine ORM. To test the application on another environment, I tried to install it on a Synology DiskStation. I exported the MySQL-database with phpMyAdmin and imported it to the DiskStation. But Doctrine doesn't detect the scheme either all login-credential are correct. So I tried to create the scheme with ssh-access: DiskStation> ./doctrine-module orm:schema-tool:create .../bin/doctrine-module: Permission denied Do you have any idea to

zf2 - creating models (with dependencies) in mapper without servicemanager

孤街浪徒 提交于 2019-12-12 03:34:40
问题 Following from my previous post about removing ServiceLocatorAwareInterface's from my zf2 app, i am now faced with a puzzle involving object creation when using data mappers. The current implementation of my data mapper uses a tablegateway to find specific rows, calls the service manager to obtain a domain object, then populates and returns the full object. public function findById($userId){ $rowset = $this->gateway->select(array('id' => $userId)); $row = $rowset->current(); if (!$row) {

ZF2: How to do this simple query with Zend\Db

馋奶兔 提交于 2019-12-12 03:09:02
问题 I have the following statements but they return an empty result set: $sql = 'SELECT * FROM `industry` WHERE `code` LIKE ?'; $statement = $this->getAdapter()->createStatement($sql, array('A_')); $statement->execute(); What am I doing wrong? I really don't want to use the Zend\Db\Sql\Sql, as it is very verbose. On a related point, where can I go to find out more about the theory of operation for Zend\Db? It's absolutely maddening. Why does it sometimes return a driver result? Sometimes a

display json value in select tag(view) zend framework 2

左心房为你撑大大i 提交于 2019-12-12 02:55:51
问题 my model: to fetch the data from database public function getAllProjectDomain() { $dbadapter = $this->adapter; $sql = new Sql($dbadapter); $select = $sql->select(); $select->columns(array('cmain')); $select->from('projcat'); $selectString = $sql->getSqlStringForSqlObject($select); $result = $dbadapter->query($selectString, $dbadapter::QUERY_MODE_EXECUTE); foreach ($result as $row) { $entity = array( "domain" => $row->cmain ); $entities[] = $entity; } return $entities; } my controller: public

ZF2 FormInput to show error class on validation fail

穿精又带淫゛_ 提交于 2019-12-12 02:38:22
问题 My form has multiple elements being rendered in the format: <div class="form-group"> <?php echo $this->formlabel($form->get('lastname')); ?> <?php echo $this->forminput($form->get('lastname')); ?> <?php echo $this->formElementErrors($form->get('lastname')); ?> </div> I do this so I can have my element next to my label as opposed to inside it: <label for="lastname">Lastname</label><input .../> <ul><li>error messages</li></ul> What I have noticed is that on validation fail the input is not

Zend Framework 2 - Doctrine 2 Error message

被刻印的时光 ゝ 提交于 2019-12-12 02:35:54
问题 I have been trying to add more flexibilities to the Album Module from Zend Framework 2. In that process I have been trying to set a validator for one of the form fields especially for the album name which in my case the column name in my database is title. I have been following the validation part from one of the previous answers to my post, which can be found here I have been using that class in my albumcontroller class in this fashion: <?php namespace Album\Controller; use Zend\Mvc