zend-framework2

How to show zf2 errors?

折月煮酒 提交于 2019-12-01 12:21:47
问题 I've reinstall my system and now when something wrong in zf2 i cant see the error on the page only in nginx error log, the display_errors On and display_startup_errors On, in php.ini, maybe something with my php-fpm settings? And in the simple php file not in zf2 i have see the errors! 回答1: You need enable the following options in your config 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, ) Remember turn off this in a production environment 回答2: ini

ZF2 Doctrine 2 ObjectSelect with distinct on field

空扰寡人 提交于 2019-12-01 11:26:05
问题 to populate my form I use the fieldset approach. For one given form field I will use a select and the options are coming directly from an entity like this: $this->add( array( 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'name' => 'city', 'options' => array( 'label' => 'City: ', 'object_manager' => $this->_om, 'target_class' => 'Hotbed\Entity\AllAdresses', 'property' => 'city', 'is_method' => true, 'find_method' => array( 'name' => 'findBy', 'params' => array( 'criteria' => array(

Set & Access Variables in error Page ZF2

Deadly 提交于 2019-12-01 11:06:06
问题 class FrontController extends AbstractActionController { public function indexAction() { $this->layout()->setting_data = $this->getSetting()->getSettingContent(1); return array(); } } public function getSetting() { return $this->getServiceLocator()->get('Front/Model/Setting'); } class Setting extends AbstractTableGateway { public function __construct($adapter) { $this->table = 'setting'; $this->adapter = $adapter; } public function fetchAll() { return $this->select(); } public function

ZF2 Controller Plugin

淺唱寂寞╮ 提交于 2019-12-01 10:52:12
I'm new to ZF2 and am having some trouble with what should be a basic idea. I'm using the ZfCommons User module for authentication, it's been installed and is operating properly. Now I want validate the user is in fact logged in from my controller based on this ( How to check if the user is logged in but I can't figure out out how to register the controller plugin, I'm currently receiving this error: Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for ZfcUserAuthentication My Controller looks like this: <?php /** * Zend Framework (http://framework.zend.com/) *

Zend Framework - Returning Image/File using Controller

 ̄綄美尐妖づ 提交于 2019-12-01 10:37:47
I am new to Zend Framework 2 and only know a little basics. I find it difficult to find a lot of examples as well. Quesiton: Get BLOB field in database and display it through a controller. For example: www.mysite.com/images/2 will retrieve a BLOB from the database and display it to the user as an image so an html tag like <img src="http://www.mysite.com/images/2"/> will display an image. I normally do it in ASP.NET MVC but have no clue how to do it here. I would be delighted if some one could enlighten me on how to achieve it. Assume that I have fetched the image from the database. I managed

Button content in ZF2 forms

纵然是瞬间 提交于 2019-12-01 09:21:26
How to edit the button content of a Button element (of a ZF2 form)? I can set a label, but i would like to insert some html code inside it. $this->add(array( 'type' => 'Button', 'name' => 'submit', 'options' => array( 'label' => 'Modifica', ), 'attributes' => array( 'type' => 'submit', 'class' => 'btn btn-warning' ) )); Thanks You can simply use the disable_html_escape label's option. It works for me. $this->add(array( 'type' => 'Button', 'name' => 'submit', 'options' => array( 'label' => '<i class="icon icon-foo"></i> Submit', 'label_options' => array( 'disable_html_escape' => true, ) ),

ZF2 skeleton application is throwing 500 error

两盒软妹~` 提交于 2019-12-01 09:07:35
When trying to deploy the skeleton application using the following commands: git clone git://github.com/zendframework/ZendSkeletonApplication.git cd ZendSkeletonApplication php composer.phar self-update php composer.phar install I get the following error: PHP Fatal error: Uncaught exception 'Zend\\ServiceManager\\Exception\\InvalidArgumentException' with message 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' in /home/web/www/zftests/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/ServiceManager

Zend Framework - Returning Image/File using Controller

懵懂的女人 提交于 2019-12-01 08:46:54
问题 I am new to Zend Framework 2 and only know a little basics. I find it difficult to find a lot of examples as well. Quesiton: Get BLOB field in database and display it through a controller. For example: www.mysite.com/images/2 will retrieve a BLOB from the database and display it to the user as an image so an html tag like <img src="http://www.mysite.com/images/2"/> will display an image. I normally do it in ASP.NET MVC but have no clue how to do it here. I would be delighted if some one could

How to use a custom form view helper in Zend Framework 2?

两盒软妹~` 提交于 2019-12-01 08:25:32
I wrote a form view helper, that extends the Zend\Form\View\Helper\FormMultiCheckbox and overwrites its renderOptions(...) method: <?php namespace MyNamespace\Form\View\Helper; use Zend\Form\View\Helper\FormMultiCheckbox as ZendFormMultiCheckbox; class FormMultiCheckbox extends ZendFormMultiCheckbox { protected function renderOptions(...) { ... $label = $escapeHtmlHelper($label); $labelOpen = $labelHelper->openTag($labelAttributes); switch ($labelPosition) { case self::LABEL_PREPEND: $template = $labelOpen . $label . $labelClose . '%s'; break; case self::LABEL_APPEND: default: $template = '%s'

PHPUnit with a Zend Framework 2 module

柔情痞子 提交于 2019-12-01 08:16:34
I'm struggling in getting a PHPUnit test to work with ZF2. My directory structure looks as follows project - src - config, data, module, public, vendor - init_autoloader.php - test - bootstrap.php - SimpleTest.php The application itself works well. Now for running PHPUnit tests, my bootstrap.php looks as follows putenv('ZF2=../src/vendor/zendframework/zendframework/library'); $loader = include '../src/vendor/autoload.php'; include '../src/init_autoloader.php'; This works for ZF2 related things but does not find my module. I then read that I have to add the following line to my bootstrap.php