zend-framework2

Zf3 controller not able to access the model class table located in another module

梦想与她 提交于 2019-12-22 12:11:06
问题 I am new to Zend Framework. Is there a way to access the model class table which is located in another module from my active controller? As its bye bye service locator in ZF3 i am not able to access the model class table located in other modules. Previously in ZF2 controller private configTable; public function getConfigTable() { if (!$this->configTable) { $sm = $this->getServiceLocator(); $this->configTable = $sm->get('Config\Model\ConfigTable'); // <-- HERE! } return $this->configTable; }

multiple instances of view helper plugin?

时光怂恿深爱的人放手 提交于 2019-12-22 11:46:51
问题 How do I instantiate multiple instances of a view helper plugin in Zend 2? I want to return a new instance every time I call $this->pluginName(); from the view. How do I return a new instance of the view plugin? 回答1: Add the service name to the getViewHelperConfig() shared configuration key in Module.php and set this value to false Module.php function getViewHelperConfig() { return array( 'shared' => array( 'MyViewHelper' => false, ), 'factories' => array( 'MyViewHelper' => 'App\View\Helper

Extending Zend\View\Helper\Url in Zend Framework 2

不打扰是莪最后的温柔 提交于 2019-12-22 10:57:36
问题 I wrote a simple url view helper, that extends Zend\View\Helper\Url and attached it to the ViewHelperManager : MyNamespace\View\Helper\Url namespace MyNamespace\View\Helper; use Zend\View\Helper\Url as ZendUrl; class Url extends ZendUrl { public function __invoke($name = null, array $params = array(), $options = array(), $reuseMatchedParams = false) { $link = parent::__invoke($name, $params, $options, $reuseMatchedParams); ... return $link; } } Application\Module namespace Application; use ..

using Zend_Db zf2 module outside of zf2 mvc

六眼飞鱼酱① 提交于 2019-12-22 10:43:50
问题 I'm writing a PHP application that is not based on zf2 mvc. I do want to use only the Zend_Db zf2 module. how can I configure my application to know how to find the Zend_Db releveant PHP file where required ? I have zf2 Zend_db module download with phyrus and installed at the location vendor/zf2/php . I tried adding the module to the include path with the following command: set_include_path("../vendor/zf2/php".PATH_SEPARATOR.get_include_path()); I created Model class files relevant to each

validating date in zendframework2

只谈情不闲聊 提交于 2019-12-22 10:04:10
问题 Hiho, I would like to validate a date field from an zf2 form. I set the 'format' option to get the format I need. But at every time I validate it i get an error. The validator looks like this: $inputFilter->add($factory->createInput(array( 'name' => 'user_data_birth', 'required' => false, 'validators' => array( array( 'name' => 'Date', 'options' => array( 'format' => 'd.m.Y', 'locale' => 'de', 'messages' => array( \Zend\Validator\Date::INVALID => 'Das scheint kein gültiges Datum zu sein.',

UniqueEntity using Doctrine 2

心已入冬 提交于 2019-12-22 09:52:25
问题 I am using Zend Framework 2 and I have created a User Entity. Now I am trying to make the username field unique. However the following error is coming up. [Semantical Error] The annotation "@UniqueEntity" in class User\Entity\User was never imported. Did you maybe forget to add a "use" statement for this annotation? I have added this code for uniqueness check @UniqueEntity("email") I can see that it is a method used in Symfony. How can I use it for Zend Framework 2? This is the Entity I am

Generate PDF file with Zend Framework 2 [closed]

≯℡__Kan透↙ 提交于 2019-12-22 09:39:26
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm started to learn ZF2 right now and notice that there's no "Zend_Pdf" or similar on zend framework 2... How can I create pdf on this version of the framework? Anyone knows a good tutorial? 回答1: Zend Framework 2 has moved many of the old Zend Framework libraries out of the main core and created modules instead

Give permission for bjyauthorize to run mvc application of ZF2 from CLI

拟墨画扇 提交于 2019-12-22 08:55:06
问题 I have a completely running mvc application on ZF2. I want to run some actions from command line. I have properly set up my console routes and other environments. When I run my app from CLI, I got Permission denied exception like this: 'You are not authorized to access GeneratePdf\Controller\GeneratePdf\GeneratePdf:generate-all' in /var/www/zf2-reporting/module/BjyAuthorize/src/BjyAuthorize/Guard/Controller.php‌​:172 I already have some user in my database. How can I use those credentials to

Parent Child Relationship With A Single Entity In Doctrine 2

試著忘記壹切 提交于 2019-12-22 06:27:10
问题 I have database table that looks like this: +----+--------+--------------------+ | id | parent | description | +----+--------+--------------------+ | 1 | null | P Cat 1 | | 2 | 1 | Child 1 of P Cat 1 | | 3 | 1 | Child 2 of P Cat 1 | | 4 | null | P Cat 2 | | 5 | 4 | Child 1 of P Cat 2 | | 6 | 4 | Child 2 of P Cat 2 | +----+--------+--------------------+ How can I create a doctrine 2 entity that has these columns, but I need the parent column to reference the "id" column as a parent. Of course,

How to create database in doctrine 2

无人久伴 提交于 2019-12-22 05:09:32
问题 I would like to create a database with doctrine 2 and zend framework 2. I tried to use the command line but it doesn't work because first of all I need to be connected to a database. Here is the command line that I could use : When I use the command "php doctrine dbal:run-sql CREATE DATABASE TOTO", I receive an error which tells me that I the database that I selected (but I don't want to select any database) is unknown. Do you have any idea how I can figure out this problem ? I really