FAQ Database Discussion Community


How to upload a file using zend HttpClient?

php,rest,file-upload,zend-framework2
I'm using HTTP client. How to attach a file while sending a post request? Here's my code: function executePost($postdata = [], $full_file_path = ''){ self::$client = new Zend\Http\Client(null, ['timeout' => 30] // updated to 30 sec ); self::$client->setEncType(Zend\Http\Client::ENC_URLENCODED); self::$client->setUri($url); self::$client->setMethod($method); self::$client->setParameterPost($postdata); $response = $client->send(); Debug::dump($response->getContent(),$label='Response',$echo=true); } I have tried...

ZF2 - Trigger MvcEvent::EVENT_DISPATCH_ERROR from View Controller

php,zend-framework2,zend-framework-mvc
I am using a Restful Controller and on certain conditions, I would like the trigger the MvcEvent::EVENT_DISPATCH_ERROR and stop execution of the controller immediately after. In my Module class, I have attached an event listener for this but I can't find a way to trigger it from the view controller....

Error in Array comparison in php

php,arrays,zend-framework,foreach,zend-framework2
Below are the sample arrays I'm Comparing. Table 1 $csvData= ( [0] => Array ( [Account Number] => 1.01100156278101E+15 [Posting Date] => 2014/07/08 [Value Date] => 2014/07/08 [Description] => Cash Withdrawal by Cheque-173320--TT1421957901 [Debit Amount] => 2000 [Credit Amount] => [Running Balance] => 388392.62 ) [1] => Array ( [Account...

Best way to configure a Table in Module.php - Zend 2

php,zend-framework2
I am setting up my tables in module.php using the default example in zend2 tutorial, but in my project I have so much tables, so my module.php is too large. Here is my default config EXAMPLE 1: 'UsersTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new...

Zend Framework 2 - Accessing 2 different tables from same controller file

php,mysql,module,zend-framework2,tablegateway
I have succesfully completed the the album table tutorial in Zend Framework 2 manual. I have implemented using tablegateway. I can see that he used only one table named "album" and hence he implemented according to that one table. Lets say I have another table called "artist" that holds the...

How to get a $_POST request from view module?

php,html,forms,zend-framework,zend-framework2
I want to get the checkboxes from a table in a view module, but I can't get it to work. This is the table: <form action="" method="post"> <TABLE id="dt_basic" class="table table-striped table-bordered table-hover dataTable"> <THEAD> <TR> <TH></TH> <TH>ID</TH> <TH>Client</TH> <TH>User</TH> <TH>Role</TH> <TH>Projects</TH> </TR> </THEAD> <TBODY> <?php /* @var $item Admin\Model\User...

Create a subquery using ALL and ANY statements

mysql,zend-framework2,any
I'm trying to make this query SELECT * FROM district WHERE id = ANY (SELECT districtId FROM address WHERE id = ANY (SELECT addressId FROM schedule WHERE workshopId = '1')) My real problem is inserting the ANY statement. Does anyone know how to apply ANY or ALL to the query...

Setting up ServiceManager with configuration files in Zend Framework 2

zend-framework,dependency-injection,zend-framework2,servicemanager
I have read ZF documentation about ServiceManager and think configuration (even in "config" php files) like public function getServiceConfig() { return array( 'invokables' => array( 'my-foo' => 'MyModule\Foo\Bar', ), ); } is very long and verbose. And, if I have a lot of dependencies, I want to use some sort...

Mocking service with PHPUnit in Zend Framework 2

php,unit-testing,zend-framework2,phpunit
I am trying to mock a delete Action. The delete method is inside a service, so I would like to mock the service that is requested inside the controller. This is the delete action: public function deleteAction() { try { $internId = $this->params()->fromRoute('id', 0); $this->getServiceLocator()->get('internService')->removeIntern($internId); } catch (Exception $e) {...

How To Use toRoute in ZF2 View Helper

zend-framework2,zend-view
I really did not wanted to ask this question but now I can't help. I want to use toRoute or redirect controller plugin in my view helper. I know View helpers extend functionality on the view layer and are for reusability throughout our application. Controller plugins extend functionality on the...

Zendframework 2 postgresql update with “not”

postgresql,zend-framework2,tablegateway
Is is possible to pass to database the following sql query using tableGateway, if so, how would such a command look like ? UPDATE table_data SET active = not active where table_data.id = 12; ...

Ajax - doesn't change URLs

javascript,php,jquery,ajax,zend-framework2
I made the contents of the page change using Ajax, but the problem is the site url stays the same, therefore it doesn't load the page at all, just the text on it. So for example, I click on the Login link and the content changes, but the url stays...

Password protecting Apigility admin UI without htpasswd

zend-framework,zend-framework2,apigility
I was being searching to password protect apiglity admin ui without using htpasswd, but i did not got any information about. Can anybody help me out with this? Thanks in advance...

ZF2 changing my expression and returning error (Postgre, Distinct)

php,sql,postgresql,zend-framework2
I have to make a SELECT where I will distinct the rows by the column idcontrato. I did it well with with SQL... SELECT DISTINCT ON (idcontrato) * FROM cad_emprestimo WHERE numerobeneficio = '1135346515'; But when I try to do the same with ZF2: $emprestimos = (new EmprestimoTable())->select(function(Select $select) use($cliente)...

Zend Framework 2 Form Errors Not Showing

zend-framework2,zend-form
I am trying to figure out why Zend Form is not returning errors to my form. When I take a look inside the: Zdendframework/library/form/form.php file I can see the errors are being generated: public function isValid() { if ($this->hasValidated) { return $this->isValid; } ... if (!$result) { $this->setMessages($filter->getMessages()); } return...

PHP ZF2 Mysql has gone away

php,mysql,zend-framework,zend-framework2
Hi I have a php daemon that handle request from rabbitmq After a day, it can no longer execute due to error MySQL has gone away. PHP Warning: PDOStatement::execute(): MySQL server has gone away in /var/www/daemon/www/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on line 239 PHP Warning: PDOStatement::execute(): Error reading result set\'s header in /var/www/daemon/www/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on...

Validator EmailAddress can validate an array of email

php,validation,email,zend-framework2,jquery-select2
I have a select2 field (tags) wich need to be validated with EmailAddress validator from Zend framework 2. the post from select2 field is like this : '[email protected], [email protected]' From here, my form has an input filter wich looks like this : public function getInputFilterSpecification() { return array( 'name' =>...

CORS POST request in ZF2 becomes OPTIONS request instead

php,zend-framework2,cors
Is there anyway in Zend Framework 2 to allow CORS on my API? I have already allowed all origins header("Access-Control-Allow-Origin: *"); Every time I send a POST request with headers the server responds with 405. On my access log I see the the request is actually OPTIONS...

jQuery Ajax unable to send PUT and DELETE REST API to ZF2 server

jquery,ajax,rest,zend-framework2
I am having problem sending PUT and DELETE REST API from my front end to my ZF2 backend. However: I am able to send POST and GET request and it's working fine but not PUT and DELETE won't. Why? Below is my ajax code: $.ajax({ type: "PUT", dataType: "json", data:...

Zend Framework - How to resolve catchable fatal error on argument 1 of model constructor invocation?

php,zend-framework2,wampserver
Scenario: After setting up the Zend Framework Latest Skeleton App and setting up debugging in my local PHP Debugger Tool Eclipse environment, I have come across an issue while setting up my first model, called ActionItem. As per the instructions on Zend Framework I have included getServiceConfig() in my Module.php....

Zend framework 2 PHP requirement

php,zend-framework,zend-framework2
Can we run Zend framework 2 on PHP 5.5, PHP 5.6 or any latest version? This official requirement link says: PHP 5.2.11 or later. This official FAQ link says: Zend Framework 2 is based on PHP 5.3. We expect to add support for PHP 5.4 once it starts to be...

zend framework 2 nested module structrue in one main module

php,zend-framework,zend-framework2
I am trying to create a app using zend framework 2. Have used structure as follow. Getting error class not found. Trying to created nested sub module login inside a main module called album. I have following structure: Album - src - Album - Controller - AlbumController.php - Form -...

Does Apiglity provide a buil-in error handling and logging?

error-handling,zend-framework2,error-logging,apigility
I'm working on an API project and have to decide over the error handling and logging strategy/concept. So as first step I want to check, whether Apigility provides its own logging functionality. If I see it correctly, Apigility only provides a minimal error handling for REST specific errors (Apigility documentation...

ZF2 How to set with a custom Form Element

forms,zend-framework2,checked,custom-element
How do I set checked within a form input radio field? This form field is added using a custom Form Element. The value of this field isn't consistent. My custom Form Element returns 1 element. It is a radio input field. I need this checked each and every time the...

Why is my ZF2 Segment child route being ignored?

php,routes,zend-framework2
I have the following routing config in my project: 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/', 'defaults' => array( '__NAMESPACE__' => 'MyApp\Controller', 'controller' => 'Default', 'action' => 'default', ), ), 'may_terminate' => true, 'child_routes' => array( 'api' => array(...

HTTP response returning status 0 when adding filemimetype validator to Zf2 form

php,validation,zend-framework,zend-framework2,mime-types
I had an error when i add filemimetype validator to my validator chain in one of my forms. I got an http status 0 and there aren't messages on Apache 2 logs. Does someone have an idea about what's happening? Here is the code: $fileInput->getValidatorChain() ->attachByName('filesize', ['max' => 1440000], false)...

Zend Skeleton Application album tutorial 404

php,zend-framework,zend-framework2
As far as I can see I've followed the Zend skeleton application tutorial to the letter (I actually went through it twice with the same result) but when I try to access zf2-tutorial.localhost/album I get the following error: A 404 error occurred Page not found. The requested URL could not...

PHPUnit: Testing RestFul API with die response

php,json,api,zend-framework2,phpunit
I am trying to PHPUnit test an action in my ZF2 project. The APIs return a JSON string using die($jsonObject). This causes the PHPUnit test to stop processing and just die a JSON response. public function testStartupAction() { $this->dispatch('/api/v3/startup', "POST", array()); $this->assertJson('{"status":false,"message":"Please enter the UID","data":null}'); } assetJson method is never...

ZF2 - Display image in view based on full path

php,image,zend-framework,zend-framework2
I have managed to upload image file in ZF2 and store full path in the database. Path looks like this: /home/ubuntu/NetBeansProjects/project/data/upload/event_5554a7b600c0f.jpg Project structure is a Zend Skeleton application: project data upload event_5554a7b600c0f.jpg module public In my view I call: <img src="<?php echo $event->getImage(); ?>" class="img-thumbnail" alt="<?php echo $event->getTitle(); ?>" width="304"...

integrate login to my sites with OpenId or OAuth

login,zend-framework2,oauth-2.0,openid,integrated
i have a few site developed with zend framework 1 and zend framework 2,i wanna users register in main site and in other sites i want to have a login button ,if user click on login: 1- if user logged in in main site ago , user login without enter...

How to read a curl post with PHP

php,curl,zend-framework2
I'm using curl to post JSON to PHP and i'm struggling to read the data in PHP. This is how i'm using curl , curl -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","password":"xyz"}' http://example.com/api/login This is what iv'e tried in PHP 1) Using ZF2 functions: $email = (string) $this->params()->fromPost('email', null); 2)...

ZF2 - update user profile page

php,authentication,zend-framework,zend-framework2
I am building a website using Zend Framework 2, managing authentication with ZfcUser. Now I'm working on a page where a registered user can update his profile data. I noticed that even after the user updated his data via a form, and the data are written to the database, the...

Zend 2 Navigation add before label name

php,zend-framework2
I have the following navigation array, but now i want a before my label. How and where can i add this? The output must be: <ul class="sidebar-nav"> <li class="active"> <a href="/admin/users"><i class="gi gi-user sidebar-nav-icon"></i> Users</a> </li> </ul> Array module config: 'navigation' => array( 'default' => array( array( 'label' => 'Users',...

ZF2 & Apigility - Correct way to setup GET and POST RPC services

zend-framework2,apigility
What is the correct way to setup GET and POST services in ApiGility? Currently, if I am setting up a GET service, I will include the variable I require in my route: /api/verify/merchant[/:merchant_code] And if I wish to setup a POST service, my route becomes: /api/verify/merchant And I add a...

How do I perform a query using ZF2 Firebird_PDO

php,pdo,zend-framework2,firebird
What am I doing wrong here? $adapter = new Adapter(array( 'driver' => 'Pdo_Firebird', 'database' => 'localhost:c:/firebird/mydb.fdb', 'username' => 'SYSDBA', 'password' => 'mypass' )); $sql = 'SELECT * USERS'; $statement = $adapter->createStatement($sql); $result = $statement->execute(); if I check $result->count() I always get zero (0). However I know this query should produce...

Zend Framwork 2 - Tablegateway - Updating only one column of a row in DB

php,mysql,database,zend-framework2,tablegateway
I have a table called users. It has the following columns: id name username email User can not edit any data from this table except the username column. The question is that when user wants to edit his username, what would the query be in ZF2 Tablegateway? In my controller...

ZF2 DB Adapter - Column not found: 1054 Unknown column

mysql,zend-framework2
I'm using ZF2 DB Adapter and get following error on my query: Column not found: 1054 Unknown column '"product"' But "product" is no column, it's a value, so how come? This is how I build the query: $select = $this->getGateway()->getSql()->select(); $select->join('keywordlink', 'keywordlink_ref_type = "product" AND keywordlink_ref_id = product_id', ['keyword_count' =>...

PHP/Zend Framework 2 - Unable to display table field values within dynamically generated table

php,mysql,model-view-controller,zend-framework2
Problem I am trying to display field values into a table using Zend Framework 2 and PHP/MySQL. Given the following table which is dynamically generated, I am trying to get the values shown below. Unfortunately, I only get empty values for the cell locations. Question How can I solve this...

Zend Framework 2 Cache filesystem

php,zend-framework,zend-framework2
I've been using the filesystem adapter for cacheing data. E.g.. $cache = StorageFactory::factory(array( 'adapter' => array( 'name' => 'filesystem' 'options' => array('ttl' => 1800, 'cache_dir' => './data/cache'), ), )); But when using the getItem() function AFTER the TTL clocks over it returns false on success etc, which it should... However,...

Expecting Zend to fail to find an action, but instead it finds it and tries to render a view

php,routes,zend-framework2
With an action such as public function checkImagesAction() I can request that route in my browser with /checkImages and the page is displayed using the check-images.phtml view as I'd expect. However, requesting /checkImageS or another crazy spelling causes Zend to throw a RuntimeException because it is unable to render template...

D2l first time signature is matched but next time, it displays authenticated signature?

php,api,zend-framework2,php-5.3,desire2learn
I am trying to integrate the Desire2Learn (D2L) sandbox with my app. I created an API for a D2L request. The first time, the signature is matched, but after logging out of D2L and trying once again, it then displays an authenticated signature. But when I quit and restart my...

ZF2 Segment Route doesn't match parent's constraint when using children

regex,routing,routes,zend-framework2,zend-route
I created the following routes: 'relatorios' => array( 'type' => 'Zend\Mvc\Router\Http\Segment', 'options' => array( 'route' => '/relatorios/:tipo', 'defaults' => array( 'controller' => 'Relatorios', 'action' => 'index', 'tipo' => 'normais', ), 'constraints' => array('tipo' => '(normais|administrativos)$', ), 'may_terminate' => true, 'child_routes' => array( 'view' => array( 'type' => 'Zend\Mvc\Router\Http\Segment', 'options' =>...

ZF2 - How do I get application config items within my model?

php,zend-framework2
In my job I am dealing with a legacy app running on ZF2. There is a model which is sending out a variety of different emails to difference addresses. The one thing they have in common is they all need to BCC to one particular address. At first, in my...

Fetch the maximum value of a field having same id in php

php,mysql,zend-framework,zend-framework2,zend-db-table
Here's my code,I need to return all the InstallmentDate's along with the return data,the issue here is I have same OrderInstallmentDetailsId for multiple InstallmentDate's. $select = $this->select() ->setIntegrityCheck(false) ->from(array('j' => DB_TABLE_PREFIX . 'finance_journal'), array( '*', 'JournalCreatedDate' => 'CreatedDate' )) ->join(array('jr' => DB_TABLE_PREFIX . 'finance_journal_reference'), 'j.JournalId = jr.JournalId', array( 'totalDebitAmount' =>...

zend2 mysql - joining table using TableGateway

zend-framework2
I want to aquire data from two mySql tables: SELECT L.id AS 'l_id', L.date, L.action, U.id AS 'u_id', U.name, U.surname FROM cases_log L, users U WHERE L.user = U.id LIMIT 0,30 So, I've decided to use $select->join, but it doesn't work in way I want. It has aqured data only...

zf2 album tutorial : want to not have to type index in uri

php,zend-framework2
I am new to Zend Framework 2. This question pertains to the "album" tutorial in Getting Started: A Skeleton Application I used git to install, and composer to install the dependencies. I copied the tutorial folder, set up the database, etc. It all seems to work except that I have...

ZF2 Bulk insert using INSERT INTO … SELECT from a table to same table

php,zend-framework2,bulkinsert,insert-into
I am trying to do a bulk copy of some records from a table into the same table with one field changed. But I am not able to find the correct method in ZF2 for it. My existing table looks like this : CoID -- CatCode -- CategoryName PP --...

How can I make PHPUnit ignore a file pattern?

php,zend-framework2,phpunit
I'm doing Code Coverage reports for a project and there's a ton of files that are included or required while tests are running that are not actually required to be tested or added to coverage reports (I'm using Zend Framework 2; config + Module files are the culprit here). Is...

Zend 2 After login how to set user

zend-framework2,zend-db
I have the following code and which works, but now the next step. How and where do i have to set a session so the script "sees" that the user is already logged in? if ($form->isValid()) { $securePass = $this->getUsersTable()->getUserByUsername( $this->params()->fromPost('username') ); if( $securePass ){ $bcrypt = new Bcrypt(); if...

Doctrine PDOException No such file or directory

doctrine2,zend-framework2
I am using ZF2 with DoctrineOrm and have recently installed a local environment using vagrant on my mac running OSX (Yasomite). Everything works as expected except I get the following error when I attempt to use Doctrine vendor tools: ./vendor/bin/doctrine-module orm:schema-tool:create --dump-sql The error reads: Uncaught exception 'PDOException' with message...

Pass array on url using zend framework 2 routes

php,zend-framework,routes,zend-framework2
I have a web app that lets user make multiple searches and show the results of that searches all on the same page. Here's a basic structure: Search 1 - Attribute 1 = X - Attribute 3 = Y Search 2 -Attribute 2 = Z All these results are loaded...

Where to place a data array in zf2

zend-framework2
I want to create the following static data array in my zf2 project so that routing and others methods can be done based on department codes, and then view helpers and form select elements in different modules look up the department titles for the user interface. $deptList = array( '01'...

The class 'Doctrine\ORM\EntityManager' was not found in the chain configured namespaces XXX

php,doctrine2,zend-framework2,doctrine
I have read the the other questions concerning this issue but have not come across a solution as of yet. I get the following error message: The class 'Doctrine\ORM\EntityManager' was not found in the chain configured >namespaces ZfcUser\Entity, Common\Entity, Employment\Entity, Intern\Entity, >Team\Entity, PurchaseRequest\Entity. I have a HolidayEntity, HolidayController, HolidayService. Adding...

ZF2 File validators return all messages but need only triggered

php,validation,zend-framework2,extract-error-message
I want to get only triggered messages, but I am getting all registred messages. $inputFilter = $factory->createInput(array( 'name' => 'image', 'required' => true, 'validators' => array( array( 'name' => '\Zend\Validator\File\IsImage', 'options' => ['message' => 'File has to be valid image.'] ), array( 'name' => '\Zend\Validator\File\Extension', 'options' => ['extension' => 'png,jpg,jpeg',...

How to add a custom hydrator strategy for doctrine Date hydrator

php,date,doctrine2,zend-framework2
I have a form which contains 3 field of type text and with a Date validator. This code is in a fieldset using doctrine hydrator (related to a doctrine entity) $this->add( array( 'name' => 'endDate', 'type' => 'Zend\Form\Element\Text', 'options' => array( 'label' => 'end_date_label', 'label_attributes' => array( 'class' => 'control-label...

Zend Framework 2 - Showing the content of a database

php,mysql,database,pdo,zend-framework2
I'm making some kind of market site with Zend Framework 2. The home got a slider showing all the products (realized with CSS3 keyframes) and some text. Both the sliding pictures and the text are read from a MySQL database. But as result, i get no output but also no...

ZF2 directory structure for lots of applications

php,zend-framework,zend-framework2,directory,structure
I'm learning ZF2 and I need some help. I am working in a company which has an intranet. We have lots of applications like newsletter, HR, website control, helpdesk, etc. Is it correct to put all the applications in the same ZF2 directory structure as if they were modules? Like...

How to make Zf2 Apigilty accept client request with no Accept set in header

php,zend-framework2,apigility,content-negotiation
Recently I have upgraded my rest server to Zf2 Apigility, which the content negotiation settings are as follows, 'zf-content-negotiation' => array( 'controllers' => array( 'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => 'Json', ), 'accept_whitelist' => array( 'CloudSchoolBusFileApi\\V1\\Rest\\FileReceiver\\Controller' => array( 0 => 'application/vnd.cloud-school-bus-file-api.v1+json', 1 => 'application/json', ), ), 'content_type_whitelist' => array(...

ZF2 - overriding navigation menu view helper function

php,zend-framework2,view-helpers
I'm trying to extend the Zend\View\Helper\Navigation\Menu helper class with my own and override accept function. Based on ZF2 register custom helper for navigation question, my Menu helper class looks like this: <?php namespace Application\View\Helper\Navigation; use Zend\View\Helper\Navigation\Menu as ZendMenu; use Zend\Navigation\Page\AbstractPage; class Menu extends ZendMenu { public function accept(AbstractPage $page, $recursive...

ZF2 Doctrine with Symfony < OR null query

symfony2,doctrine2,null,zend-framework2
How do I write this "WHERE" condition in a way which is compatible with Doctrine? ( ( `translations_es_google`.`translation_date` < `translations_masters`.`translation_date` ) OR ( `translations_es_google`.`translation_date` is null ) ) What I have tried (unsuccessfully) are: $query1 ->andWhere('((t.translationDate < m.translationDate) OR (t.translationDate is NULL))'); $query1 ->andWhere('(t.translationDate < m.translationDate) OR (t.translationDate is NULL)');...

Zend InputFilter requires intl PHP extension?

php,zend-framework,zend-framework2
I am setting up some filters and validators for my form, but when I submit it, this error appears: "Zend\I18n\Filter component requires the intl PHP extension". Is this because of the Alnum and Alpha validators ? Code: public function getInputFilter() { if (!$this->inputFilter) { $inputFilter = new InputFilter(); $inputFilter->add(array( 'name'...

Zend Framework 2: Create Search Widget for Layout

php,zend-framework2
I have a small private Project to learn ZF2. I have integrated Zend Lucene as a Search Function. This works well, but I now want to integrate a Search Field in my Layout, so that it is available on all pages. I am really not sure how to achieve this....

Zend Framework 2 routing error: resolves to invalid controller class or alias

zend-framework,routing,zend-framework2,zend-framework-mvc,zend-framework-routing
I'm trying to learn Zend Framework 2 and I have their skeleton application up and running. In order to access it I visit http://localhost:8080/. When visiting that link it displays their generic Zend page. What I want to be able to do is visit http://localhost:8080/application/test and have it bring me...

OnDispatch event in Service Constructor

php,zend-framework2,apigility
I have problem with attaching OnDispatch event in Apigility. I want to have value from custom header in constructor of my abstract Service Class. It works when I simply add it to on bootstrap in Module.php public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH,...

Zend 2 Translation global

php,zend-framework2
The following code works fine in a controller,how global? XXXController.php $lang = 'nl'; $loc = $this->getServiceLocator(); $translator = $this->get('translator'); $translator->addTranslationFile("phparray",'./module/admin/language/lang.array.'.$lang.'.php'); $loc->get('ViewHelperManager')->get('translate')->setTranslator($translator); View.phtml echo $this->translate('homepage'); The awnser: module.config.php 'translator' => array( 'locale' => 'it_IT', 'translation_files' => array( array( 'type' =>...

Apigility - Invalid content type specified

configuration,zend-framework2,apigility
I am attempting to post login credentials to an apigility login API: $response = ClientStatic::post( 'http://www.example.com/api/login', array('email' => '[email protected]','password' => 'test'), array('Accept' => 'application/json') ); This returns the error: Cannot honor Accept type specified As far as I can tell, application/json has been whitelisted in the configs: Any ideas? My...

How to route pages using text instead of IDs?

zend-framework,zend-framework2,zend-route,zend-router
Currently, my Zend application routes using the URL: example.com/news/12 Selects the news with ID 12 to display on page. But the client wants to use only text, example: example.com/news/man-dies-after-burning-himself Does someone knows how can it be done?...

Php Mysql select query not working

php,mysql,zend-framework,zend-framework2
The below query results in the following error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'AccountId' in where clause is ambiguous $select = $this->select() ->from(array('finance_account' => DB_TABLE_PREFIX . 'finance_account'), array( 'AccountId', 'ParentAccountId', 'AccountGroupId', 'AccountPath', 'AccountCode', 'AccountName', 'Description' )) ->joinLeft(array('ac' => DB_TABLE_PREFIX . 'customer'), 'finance_account.AccountId = ac.AccountId', array()) // using "array_unique()" to...

cannot get the values from an array

php,csv,multidimensional-array,zend-framework2,fgetcsv
This is a sample array from a csv file upload, which I'm working on $csvData = array(7) { [" Account Number"]=> string(32) " 1011001562781010" [" Posting Date"]=> string(10) "07/08/2014" [" Value Date"]=> string(10) "07/08/2014" [" Description"]=> string(46) "Cash Withdrawal by Cheque173320--TT1421957901" [" Debit Amount"]=> string(7) "2000.00" [" Credit Amount"]=> string(0)...

Routing problems in ZF2 : Controller not mapped

php,zend-framework2,zend-route
I'm trying to create a simple CRUD in Zf2 to get to know it and I'm having problems routing the only controller I have. I have this error; "The requested controller could not be mapped to an existing controller class". I'm trying to call this route : http://zf2.local/Listapp This is...

How to get the Basic HTTP Authentication working for an Apigility application?

php,authentication,zend-framework2,basic-authentication,apigility
I set up the Basic Auth as in the Apigility docu described (the docu is not up to date anymore, but the main steps are staying the same). So, I created a users.htpasswd file and added an authentication adapter. My /config/autoload/local.php has been updated and got the adapter configs: return...

ZF2 Pagination does not work with Union

php,mysql,pagination,zend-framework2,union
I am using PHP with Zend Framework 2.3.3. I used Paginator for a Select with a Union. The code is like this: $where = new Where(); $where->like('value', "%$infoToSearch%"); $select = new Select(); $select->columns(array(new Expression('DISTINCT(id)'))); $select->from('products'); $select->where($where); $select2 = new Select(); $select2->columns(array(new Expression('DISTINCT(id)'))); $select2->from('products_archive'); $select2->where($where); $select->combine($select2); $paginatorAdapter = new DbSelect($select,...

zf2 + doctrine2 and No Metadata Classes to process

php,doctrine2,zend-framework2,metadata
I'm using tutorial http://www.nuvolia.com/2013/03/09/zend_framework_doctrine_install/. The module Application fork fine with Doctrine ORM but when i'm tring to connect in another module i'm reciving error: d:\Aptana Studio\Projects\app01>vendor\bin\doctrine-module orm:schema-tool:create Deprecated: "Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Qu estionHelper" instead. in D:\Aptana Studio\Projects\app01\vendor\symfony\console...

ZF2 / Doctrine / Cannot remove all elements from an ArrayCollection

php,doctrine2,zend-framework2
I have 2 entities, Product and Category with a bidirectional ManyToMany association mapping defined below : Product /** * @ORM\ManyToMany(targetEntity="Category", inversedBy="products") * @ORM\JoinTable(name="products_categories") */ protected $categories; // with these accessors public function addCategories(Collection $categories) { foreach ($categories as $category) { $this->addCategory($category); } return $this; } public function addCategory(Category $category) {...

zend2 adding another controller to application

controller,routing,zend-framework2
I'm working on a ZendFramework2.4-project. I just got started an filled the IndexController of a standard skeleton application with some code and thought of another controller in the same application. No new modul, just a second Controller to keep code seperated. Of course I read the documentation at Zend2: Routing...

Composer + Rocketeer + ZF2- Cannot install Rocketeer due to requirements conflict

php,zend-framework2,composer-php,rocketeer
Can somebody can tell me how to fix this? Rocketeer installs just fine in empty dir, but not along with my existing project, don't know w why. What is requiering that installation? - Installation request for symfony/console == 2.6.6.0 -> satisfiable by symfony/console[v2.6.6]. composer.json { "name": "zendframework/skeleton-application", "description": "Skeleton Application...

is not null condition in zend framework 2

php,mysql,sql,zend-framework,zend-framework2
I am new to zf and I've started working with zf2, I don't find much documentation for the syntax and all. My issue is how to write is not null condition in zf2 syntax. $select->where->notEqualTo('pe_name', ''); I've written for not equal to, now I need for is not null. I...

delete parameters in URL

zend-framework2
I have kind of a basic understanding problem. If I start my application: http://localhost/cheyenne/public/ I have of course no post parameters in my start url If I take a link with post parameters like edit for example, I get this URL http://localhost/cheyenne/public/arbeitskalender/edit/nr/2 still everything is fine If I take another...

Cant set config caching options in a local config?

php,zend-framework2
I'm working on setting up config caching in a zf2 application. Putting the settings in application.config.php seems to work fine... // config/application.config.php 'module_listener_options' => array( 'module_paths' => array( './module', './vendor' ), 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php' ), 'config_cache_enabled' => true, 'config_cache_key' => 'my_cache_key', 'module_map_cache_enabled' => true, 'module_map_cache_key' => 'my_cache_key', 'cache_dir' =>...

Overriding ZF2 global/local config: unsetting

zend-framework,zend-framework2
I've run into a problem where my local config overrides global but I need local to remove not just override. E.g. // global.php 'mail_transport' => [ 'type' => 'Zend\Mail\Transport\Smtp', 'options' => [ 'host' => 'smtp.gmail.com', 'port' => 587, 'connectionClass' => 'login', 'connectionConfig' => [ // ... ], ], ], //...

zf2 call a method from a Model in another Model

model-view-controller,zend-framework2
I have a couple of modules in ZF2 project. Each module has different model classes performing different required functions. Now I have method in a model class of first module which I want to call in the model class of second module. Is it possible to do so? if yes,...

2 forms same view zf2 doctrine

forms,entity-framework,doctrine2,zend-framework2
I have a project in ZF2 and Doctrine. I have an Action that has 2 forms each with its own entity. Already I can print both in my view. But now I need to save these two forms one of each entity in the bank. Just 1 submit button. How...

unwanted response text in rest apigility

php,zend-framework2,apigility
use apigility to get json response in postman when i send post request in postman and return response like this { "\u0000*\u0000version": null, "\u0000*\u0000contentSent": false, "\u0000*\u0000recommendedReasonPhrases": { "100": "Continue", "101": "Switching Protocols", "102": "Processing", "200": "OK", "201": "Created", "202": "Accepted", "203": "Non-Authoritative Information", "204": "No Content", "205": "Reset Content", "206":...

Select a dummy column with a dummy value in zend frame work 2

mysql,zend-framework2
$SQL = "SELECT '' as name,'' as id FROM `student`" if do like this errors are showing $select->columns(array(''=>'name')); is there any alternate way?...

Zend 2 redirect() module error

zend-framework2
I have made a checklogin fucntion to check $auth->getIdentity(), but i am getting the following error: Fatal error: Call to undefined method Admin\Module::redirect() in C:\xampp\websites\zend2\module\Admin\Module.php on line 51 How can i fix this? public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $app = $e->getParam('application'); $app->getEventManager()->attach('render',...

Uncommon usage of form attributes in ZF2

php,zend-framework2
I'm writing a simple CMS, where on each page users can edit all its attached languages. For example, the raw $_POST input when a user submits a form, typically must look like as following: array( 'fr' => array( 'name' => 'Some name in French', 'content' => 'Some content in French'...

Fieldset zf2 - populate 2 entities

php,zend-framework2,doctrine
I have a form by adding a fieldset and fieldset that calling another. I have only one ManyToOne relationship referencing the ID of the another entity. in my controler I have: public function juridicaAction() { if (!$this->zfcUserAuthentication()->hasIdentity()) { return $this->redirect()->toRoute('login'); } $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager'); $em = $this->getEntityManager(); $pessoajuridica = new...

ZEND_Auth, deactivate navigation area

zend-framework2,zend-form,zend-layout
I´ve built a Login Page using Zend_Auth. Now my question ist how can I deactivate areas which are loaded with my layout.phtml? Here the part of my code of my layout.phtml which I don´t want to see in my login and logout forms: <div id="navigation"> <ul> <li><a href="<?php echo $this->url(array('controller'=>'arbeitskalender',...

Zend2 - ZF2 - Routing Issue

php,zend-framework2
i am trying to make my router working so that: /Auth redirects to Auth controller of Auth MOdule /Auth/Login redirects to Login controller of Auth Module While the first works just right the /Auth/Login results in routing issue. My router configuration file looks like below: 'router' => array( 'routes' =>...

BETWEEN with range including '1' also returns '10'

php,mysql,zend-framework2,between
I'm getting some unexpected behaviour using a BETWEEN predicate in ZF2. Consider the following code: $ranges = array( array( 'min' => 2, 'max' => 4 ), array( 'min' => 7, 'max' => 9 ) ); $predicates = array(); foreach($ranges as $range){ // create a new 'Between' predicate and add it...

ZF 2 - Fatal Error: Call to a member function getPosts() on null

php,zend-framework2,fatal-error,member-function
I am creating a website using Zend Framework 2, and I'm using as an example the exercise from the official course of Zend Technology, Zend Framework 2: Fundamentals. I have a table called posts and I want to show the table content in my home page, ordered by id. These...

Use AJAX with Zend Framework 2

jquery,ajax,zend-framework,zend-framework2
I want to use AJAX with Jquery in my ZF2 project. Exactly, I want to change select options when an over select value change. For this, I try to implement AJAX method. I don't find a good tutorial on internet for my problem, but I try to do this with...

zend framework 2 controller's action arguments

zend-framework2
I had this public function in ApplicationController public function indexAction($bar) { echo $bar; return new ViewModel(); } How I can pass this argument? I've tried http://localhost/zf2/public/application/index/index?bar=foo but this not works...

zend2 forms and action attribute

forms,zend-framework2
in my EditController I have indexAction : public function indexAction() { $delete = new DeleteForm(); $view = new ViewModel(array('delete' => $delete )); return $view; } and the view <?php $formDelete = $this->delete; $formDelete->prepare(); $formDelete->setAttribute('action', $this->url(NULL, array('controller'=>'Register', 'action' => 'process'))); ?> <?php echo $this->form()->openTag($formDelete);?> <div class="form-group"> <?=$this->formLabel($formDelete->get('reason')); ?>...

Best practice for Zend 2 FieldSets, re-use them or re-create them for every specific situation?

php,forms,doctrine2,zend-framework2
Me and my colleague were arguing about whether or not we should re-use certain Zend2 FieldSet classes in our project. Using the framework we create many different forms, and there are quite a few forms for which the same information needs to be filled in. For example, we have a...

ZF2 inserting data to Db

zend-framework2
During saving I recive an error: values() expects an array of values or Zend\Db\Sql\Select instance I think error comes from: $this->tableGateway->insert($procedure); I don't understand what is wrong. This is my process function: public function processAction() { if (!$this->request->isPost()){ return $this->redirect()->toRoute(null, array('controller'=>'test', 'action'=>'index')); } $post = $this->request->getPost(); $form = new TestForm();...

Zend\Db Model with Child Models

zend-framework2,parent-child,zend-db,one-to-one
ZF2 project - no Doctrine, using native Zend\Db: Have the following structure: Controller ProductController Model Product ProductTable ProductType ProductTypeTable Product is the model, has variables corresponding to the “products" table fields. ProductTable is table class which is connected to the database via tableGateway. ProductTable has getItem() method to retrieve requested...

PHP Frameworks and Project Repositories

php,git,github,zend-framework2,repository
I'm starting a new in PHP and for the first time I'm going to use a framework as the basis of the project. I've decided to use Zend Framework 2 for it. I'm going to be version controlling the project via Github. Is it normal to include all the framework...

Ajax upload file in PHP

javascript,php,jquery,ajax,zend-framework2
In my PHP app I have some content generated by AJAX with form having file input. This form is located in Bootstrap Modal. I write some data into inputs and upload file using jQuery File Upload Plugin 5.26 and it works fine. I close modal and load the same content...

how retrieve array returned by config in zend framework 2

zend-framework2
How I can get the array returned by config/autoload in zend framework 2? #config/autoload/myconfig.local.php return array('foo' => 'bar'); I noticed if the file have not "return array()" an exception will throw...