zend-framework2

Fatal error: Class 'Zend\Loader\AutoloaderFactory' not found in init_autoloader.php

↘锁芯ラ 提交于 2019-12-12 22:32:34
问题 I had successfully tested my ZF2 application on my test server. When I published the application to the live server I got the following error: Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable. This error disappeared after adding this line to my index.php. putenv("ZF2_PATH=/opt/zf2/library/"); But now I get the AutoloaderFactory-not-found error instead, which means PHP still doesn't find the classes. The live server is a 1und1 (1and1, 1&1) managed

Zend Framework 2 - Building a simple form with Validators

眉间皱痕 提交于 2019-12-12 21:51:29
问题 I'm trying to build a VERY simple form and want to add the validation in the form itself. No need for million lines of code when adding it in the form just is about 3 lines. Here are two of my fields: $this->add(array( 'name' => 'username', 'attributes' => array( 'type' => 'text', ), 'options' => array( 'label' => 'Name*', 'required' => true, ), 'filters' => array( array('StringTrim') ), )); $this->add(array( 'name' => 'email', 'attributes' => array( 'type' => 'text', ), 'options' => array(

ZF2 - How to Listen for Events and Trigger a Service because of it?

家住魔仙堡 提交于 2019-12-12 20:44:54
问题 Have been trying to learn how to implement Services because they get Triggered by a Listener. Have been doing a serious lot of reading the last few days to get it to work, but have been finding it difficult. Thus I'm thinking my understanding of the order of things might be flawed. The use case I'm trying to get to work is the following : Just before an Address Entity (with Doctrine, but that's not important) gets saved (flushed), a Service must be triggered to check if the Coordinates for

Zend 2 - TableGateway Where Clauses

笑着哭i 提交于 2019-12-12 18:43:06
问题 Hi I am trying to get to grips with Zend 2 and I'm having some problems with where clauses in the table gateway. Below is my table class: //module\Detectos\src\Detectos\Model\OperatingSystemTable.php namespace Detectos\Model; use Zend\Db\TableGateway\TableGateway; class OperatingSystemsTable { public function findOs($userAgent) { $resultSet = $this->tableGateway->select(); foreach ($resultSet as $osRow) { //check if the OS pattern of this row matches the user agent passed in if (preg_match('/

zend framework 2 - compare 2 inputs using validator?

依然范特西╮ 提交于 2019-12-12 18:28:09
问题 I'm new to zend framework 2 and I have a question on comparing two inputs in the factory-backed form. My scenario is like following: I want to compare two inputs, for example, $startDate and $endDate . I want to validate that $startDate is always less than $endDate . How I'm going to do this? For example: $inputFilter->add($factory->createInput(array( 'name' => 'startDate', 'required' => true, 'validators' => array( array( 'name' => 'LessThan', 'options' => array( 'max' => $endDate, ), ), ),

ZF2 Testing: Failed asserting response code “302”, actual status code is “500”

无人久伴 提交于 2019-12-12 18:25:58
问题 I am implementing PHPUnit tests for an AuthenticationController . When I test the /logout route: public function testLogoutActionCanBeAccessed() { $this->dispatch('/logout'); $this->assertResponseStatusCode(302); $this->assertModuleName('Main'); $this->assertControllerName('Main\Controller\Authentication'); $this->assertControllerClass('AuthenticationController'); $this->assertMatchedRouteName('logout'); } I get the following error message: There was 1 failure: 1) MainTest\Controller

need some assistance for zf2 installation

天涯浪子 提交于 2019-12-12 18:25:17
问题 I'm using windows 7 32-bit, and xampp 1.8.1. I followed http://samminds.com/2012/07/zend-framework-2-installation-on-xampp-for-windows/ to install zf2. I downloaded 'http://msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe' and installed in " D:\Program Files\Git ". I installed my project by 'git' by the command- git clone git://github.com/zendframework/ZendSkeletonApplication.git F:\xampp\htdocs\zen and my zend skeleton was installed in " F:\xampphtdocszen " folder. the folder

How todo a orWhere in ZF2?

江枫思渺然 提交于 2019-12-12 18:07:58
问题 I'm having difficulties to create params array for ZF2 where I can do a where / or I know that orWhere is removed as of ZF2 but there are workaround which I can't get working: use Zend\Db\Sql\Predicate; $params = array( 'select' => implode(', ', array( '`user`.`id`', '`user`.`username`', '`user`.`firstname`', '`user`.`middlename`', '`user`.`lastname`', '`user`.`externalEmail`', '`user`.`email`', )), "where" => implode( new Predicate\PredicateSet( array( new Predicate\Like( '`user`.`email` =

ZF2 : Priority for Validators in InputFilter

一世执手 提交于 2019-12-12 17:27:16
问题 I have a validator on a form entry like this : $this->add(array( 'name' => 'email', 'required' => true, 'filter' => array( 'name' => 'StripTags', ), 'validators' => array( array( 'name' => 'NotEmpty', 'options' => array( 'messages' => array( \Zend\Validator\NotEmpty::IS_EMPTY => 'Veuillez renseigner une adresse e-mail.', ), ), ), array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 1, 'max' => 100, ), ), array( 'name' => 'EmailAddress', 'options' => array( ), )

How to include php class that extends an interface

喜夏-厌秋 提交于 2019-12-12 17:06:05
问题 I'm developing a socket listener that has to process data with CommandService class. CommandService.php <?php namespace Application\Service; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorAwareTrait; class CommandService implements ServiceLocatorAwareInterface { use ServiceLocatorAwareTrait; } custom.php <?php include('../module/Application/src/Application/Service/CommandService.php'); ?> And when I run on console php custom.php I get error: Fatal