zend-framework2

Zend Framework 2 Rewrite URL

孤者浪人 提交于 2019-12-20 06:27:13
问题 I have a Zend Framework 2 app and I wish to use .htaccess to rewrite some URLs. The .htaccess file is in my public folder. I have verified a simple rewrite rule which rewrites all testurl to test.php RewriteRule ^testurl/?$ test.php [NC] The test.php file is also in the public folder. I placed this rule above the Zend rule to map all URLs to index.php in .htaccess. My question is how do i rewrite this to say the SearchController in the Index Module? I have tried various rewrite rules with

Zend Framework 2 Album Tutorial 404 error occurred The requested URL could not be matched by routing MAMP OSX

為{幸葍}努か 提交于 2019-12-20 06:19:33
问题 just posted this on IRC channel ZFTalk too, Hope I can get some help on ZF2, ZF2 Album Tutorial, OSX using MAMP. Skeleton framework, homepage is working. Issue : After completing section : 8.5 Listing albums, you fill up the module/Album/view/album/album/index.phtml with some code, then they ask you to preview the page on http://zf2-tutorial.localhost/album. I get a 404, The requested URL could not be matched by routing. I headed to Google for advice. Found a GIT repository with a 'fully

Zend Framework 2 - Custom Form Validation

末鹿安然 提交于 2019-12-20 04:33:45
问题 I needed a custom form validation. So I wrote a function similar to this one. So far so good. But I really have problems where to put the PHP file/class. It was supposed to put it under vendor/ as a lib which seems logical. I used this path: vendor/company/Validator/MyValidator.php. But I couldn't figure out how to include my class. Could anyone give me a short how-to for setting up the vendor module or whatever is necessary to use a custom validator? There are a lot of tutorials on the

Zend 2: SQLSRV: $prepareParams is not being set

老子叫甜甜 提交于 2019-12-20 04:26:14
问题 Can somebody explain me where the ->setPrepareParams(array $prepareParams) is called in Zend\Db\Adapter\Driver\Sqlsrv\Statement.php? Specifically, when I used this: $this->tableGateway->select(array("Personalnummer = $personalnumber")); It worked. But when I used this: $this->tableGateway->select(array("Personalnummer" => $personalnumber)); It did not work. I tried to debug this and found that the params were not being set with my second method. 回答1: It is a public method so it is up to the

ZF2: using url helper and reuse query parameters

笑着哭i 提交于 2019-12-20 04:20:48
问题 I'm trying to reuse query params using Url helper in a view. This is my current url: http://localhost/events/index?__orderby=name&__order=asc I'm using this code in the view: $this->url('events/index', array('__page' => '2'), true); I want to obtain this url: http://localhost/events/index?__orderby=name&__order=asc&__page=2 But instead i get this: http://localhost/events/index?controller=Application\Controller\Events&__page=2 This is my route inside module.config.php file: 'events' => array(

Zend form bootstrap annotation datepicker “Object provided to Escape helper, but flags do not allow recursion”

我与影子孤独终老i 提交于 2019-12-20 03:52:43
问题 I'm using Zend framework with Bootstrap and ReverseForm adapter, and have an interesting problem with it: when I use Bootstrap Datepicker in Zend Form I've the next exception: Object provided to Escape helper, but flags do not allow recursion There is my code of formfield: use \Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use \Zend\Form\Annotation as ZFA; ... /** * @var \DateTime * * @ODM\Date * * @ZFA\Type("ReverseForm\Element\BootstrapDatepicker") * @ZFA\Attributes({"type":"text"}) *

How to pass a Doctrine ObjectManager to a form through ZF2 FormElementManager

孤人 提交于 2019-12-20 02:42:06
问题 I would like to create custom form elements in ZF2, which requires FormElementManager. I am currently using Doctrine Hydrator in the form creation as shown in this tutorial. In this method, an ObjectManager object is created in the controller and passed to the new form when it is instantiated: public function editAction() { // Get your ObjectManager from the ServiceManager $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager'); // Create the form and inject the

Zend Framework 2 Autoload Third Party library using composer

帅比萌擦擦* 提交于 2019-12-19 12:04:54
问题 I am trying to use composer to autoload a third party library into my ZF2 application - specifically Google api. I followed the answer in this post on SO, edited my composer.json "autoload": { "psr-0": {"Googleanalytics\\": "vendor/google-api-php-client/src/"} } and ran update. I can see the entry in composer/autoload_namespaces.php 'Googleanalytics\\' => array($vendorDir . '/google-api-php-client/src'), but i still get a fatal error class not found when trying to instantiate a class in that

Zend Framework 2 - Hydrator strategy not responding and hydrating

▼魔方 西西 提交于 2019-12-19 11:54:34
问题 I implemented basically this strategy. The main difference is (I guess) that I use Doctrine2 . The constructor class is called (a test echo is printed) but the two functions extract() and hydrate() are not. I added the strategy as follows: $hydrator = new DoctrineEntity($entityManager); $hydrator->getHydrator()->addStrategy('my_attribute', new MyHydrationStrategy()); $form->setHydrator($hydrator); A kind-of similar issue was posted here. Maybe the problem is in the way how I add this strategy

Zend Framework 2 custom view helpers - cross modules

*爱你&永不变心* 提交于 2019-12-19 11:22:11
问题 In Zend Framework 2, how can I have one view helper available to multiple modules? What I want is to have some general functions, like algorithmic functions, that can be reused by multiple modules. I'm currently on ZF 2 2.0.3 Thanks. 回答1: Its simple, put it in one of your modules. You can use classes and functions from other modules in ZF2. Because modules in ZF2 aren't much more than just namespaces, with some classes in them. So, if you create a view helper with the name \Module\View\Helper