zend-framework2

Zend Framework 2 Best way to implement sessions

我只是一个虾纸丫 提交于 2020-01-05 15:02:51
问题 I have a code like this: $sessionOptions = new SessionDbSavehandlerOptions(); $sessionOptions->setDataColumn('data') ->setIdColumn('id') ->setModifiedColumn('modified') ->setLifetimeColumn('lifetime') ->setNameColumn('name'); $application = $event->getApplication(); $serviceManager = $application->getServiceManager(); $dbAdapter = $serviceManager->get('Zend\Db\Adapter\Adapter'); $sessionTableGateway = new TableGateway('zf2_sessions', $dbAdapter); $sessionGateway = new DbTableGateway(

Zend Framework 2 Best way to implement sessions

可紊 提交于 2020-01-05 15:02:20
问题 I have a code like this: $sessionOptions = new SessionDbSavehandlerOptions(); $sessionOptions->setDataColumn('data') ->setIdColumn('id') ->setModifiedColumn('modified') ->setLifetimeColumn('lifetime') ->setNameColumn('name'); $application = $event->getApplication(); $serviceManager = $application->getServiceManager(); $dbAdapter = $serviceManager->get('Zend\Db\Adapter\Adapter'); $sessionTableGateway = new TableGateway('zf2_sessions', $dbAdapter); $sessionGateway = new DbTableGateway(

Zend Framework 2 Htaccess

左心房为你撑大大i 提交于 2020-01-05 12:34:25
问题 Hello guys i have problem in ZF2 with htaccess. I create vhost and all work good. when i call my-vhost.localhost all work good but when i add some uri segment like /index.php or /1234 I get 404. I edit .htaccess in public dir and put RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*$ index.php [NC,L] Bur again i have 404. Any idea how i can i slow this? My full .htaccess is : RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it.

ZF2 Captcha validation ignored when using an input filter

别来无恙 提交于 2020-01-05 12:23:31
问题 I have a form in my ZF2 app with a CAPTCHA element as follows : $this->add(array( 'type' => 'Zend\Form\Element\Captcha', 'name' => 'captcha', 'attributes' => array( 'class'=>'form-control', ), 'options' => array( 'label' => 'Please verify you are human.', 'captcha' => array('class' => 'Dumb') ), )); I have an input filter attached to the form that validates the other elements in the form (name, email, message). When this is attached to the form the validation for the CAPTCHA field is ignored

Zend Framework 2: Identical validator

会有一股神秘感。 提交于 2020-01-05 07:50:11
问题 I have problem with Identical validator in ZF2. I have created following method: public function getInputFilter() { if(!$this->inputFilter){ $inputFilter = new InputFilter(); $factory = new InputFactory(); $inputFilter->add($factory->createInput(array( 'name' => 'id', 'required' => true, 'filters' => array( array('name' => 'Int'), ), ))); $inputFilter->add($factory->createInput(array( 'name' => 'username', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' =>

How to render several barcodes with Zend 2?

我的梦境 提交于 2020-01-05 07:49:22
问题 I'm trying print several barcodes using the Zend\Barcode namespace. The problem is reading the manual I can't print more than one barcode. I can't print a echo before the barcode too. How can I print several barcodes and texts together? The code I'm using is similar to this one: use Zend\Barcode\Barcode; $barcodeOptions = array('text' => '123456'); $rendererOptions = array(); Barcode::render( 'code39', 'image', $barcodeOptions, $rendererOptions ); $barcodeOptions = array('text' => '654321');

ServiceNotCreatedException in Zend Framework 2 while attempting multiple navigations

半腔热情 提交于 2020-01-05 05:59:34
问题 I am attempting to create multiple navigation menus to use in my application based on a specific user role. The majority of the code is similar to zfc-admin. When I use zfc-admin in my application I am able to bring up an admin menu, however I will have about four roles, and decided to put this in my Application module. module.config.php 'navigation' => array( 'admin' => array( array( 'label' => 'Admin Home', 'route' => 'adminhome', ), ), 'default' => array( array( 'label' => 'Home', 'route'

How to implement acl and authorization in Module.php in zf3

会有一股神秘感。 提交于 2020-01-05 05:00:21
问题 I am working on Album Application in zf3.I added acl functionality to the application like this: AlbumController.php class AlbumController extends AbstractActionController { protected $role; public function onDispatch(\Zend\Mvc\MvcEvent $e) { $userSession = new Container('user'); if (!isset($userSession->email)) { return $this->redirect()->toRoute('login'); } else { $this->role = $userSession->role; parent::onDispatch($e); } } public function checkPermission($role,$action) { if($role ==

Zend Framework 2 Unit Tests on Jenkins not working

谁都会走 提交于 2020-01-05 03:44:09
问题 I have a zend framework 2 project and i am trying to set up my jenkins so that unit tests can be executed. Jenkins is running on ubuntu and i am developing under Windows 7 with PHPStorm. build.xml <target name="phpunit" description="Run unit tests with PHPUnit"> <exec executable="phpunit" failonerror="true"> <arg value="${basedir}/module/Addressbook/test"/> </exec> </target> Folder structure: project module Addressbook test AddressbookTest Controller AddressbookControllerTest.php Boostrap.php

Call Plugin in other Plugin ZF2

空扰寡人 提交于 2020-01-04 07:55:15
问题 in Zend Framework 2 as I can recall a plugin module A plug-in module B. If you recall the plugin from the controller, it works everywhere, but I need to call a plugin in another plugin. How can I do? 回答1: You basically have to inject PluginA into PluginB. I.e: $pluginA = new PluginA(); $pluginB = new PluginB($pluginA); echo $pluginB("Hello World"); class PluginB { protected $pluginA; public function __construct(PluginA $pluginA) { $this->pluginA = $pluginA; } public function __invoke($arg) {