zend-framework2

How to load a custom library in Zend Framework 2?

心已入冬 提交于 2020-01-29 04:25:05
问题 I've been following this guide (http://socialsemanticweb.blogspot.com.au/2012/11/zend-framework-2-create-custom-library.html) but I can't get Zend to see my library (error message below). Any ideas what could be wrong? thanks my folder structure my MyLibraryController.php <?php namespace MyLibrary\Mvc\Controller; use Zend\Mvc\Controller\AbstractActionController; class MyLibraryController extends AbstractActionController { public function __construct() { } public function doSomething() { /

ZF2 + doctrine without composer

為{幸葍}努か 提交于 2020-01-28 11:11:57
问题 I have a working ZF2 (skeleton) application and want to integrate Doctrine. I have downloaded the 2 modules (DoctrineModule and DoctrineORMModule) from github as I'm unable to use composer (so please don't answer with; "get composer"). After hours of trying to find the problem I keep getting the following error: Fatal error: Class 'Doctrine\Common\Annotations\AnnotationRegistry' not found in doctrine/DoctrineModule/src/DoctrineModule/Module.php on line 54. I have spend hours of searching and

Zend Framework 2 .htaccess mamp pro

陌路散爱 提交于 2020-01-21 19:39:06
问题 I want start to work with Zend Framework 2.0 . I use os x lion and mamp pro. So to start I used this http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html all good, I see zend project index page, but To test that your .htaccess file is working, navigate to http://zf2-tutorial.localhost/1234 and you should see this: If you see a standard Apache 404 error, then you need to fix .htaccess usage before continuing. If you’re are using IIS with the URL Rewrite Module, import

Warning: spl_object_hash() expects parameter 1 to be object, with Message

泪湿孤枕 提交于 2020-01-21 19:31:18
问题 i am getting the error when i try to flush the data, Warning: spl_object_hash() expects parameter 1 to be object along with this message Found entity of type on association Subject\Entity\Subject#user, but expecting Subject\Entity\User now here is the action i am trying to implement public function addAction() { $form = new SubjectForm(); $form->get('submit')->setAttribute('label', 'Add'); $request = $this->getRequest(); if (!$this->sessionVar) { $this->sessionVar = new SessionContainer(

Handling dependencies in Zend Framework 2 Forms

雨燕双飞 提交于 2020-01-21 07:39:26
问题 I am trying to build a form in ZF2. The problem comes when I want to populate the options array of a Select input element from a database table. A response to this question Zend FrameWork 2 Get ServiceLocator In Form and populate a drop down list by @timdev pointed me to the ZF2 docs where the 'correct' method is described. I followed this carefully but I suspect that they must have left obvious code out assuming I could fill in the gaps as I cannot get it to work. Can anyone see what I am

how to create a factory in zend framework 2?

非 Y 不嫁゛ 提交于 2020-01-21 04:47:08
问题 in my Module.php i have the fallowing methods that i would like to move them in a factory class so that i wont clutter the Module class : public function getControllerConfig() { return array( 'factories' => array( 'account-index' => function ($controllerManager) { $serviceManager = $controllerManager->getServiceLocator(); $accountService = $serviceManager->get('account-service'); return new Controller\IndexController($accountService); } ) ); } public function getServiceConfig() { return array

Factory classes vs closures in Zend Framework 2

断了今生、忘了曾经 提交于 2020-01-20 05:53:48
问题 Is it better to use factory classes or closures in Zend Framework 2, and why? I know that closures cannot be serialized, but if you return them from Module#getServiceConfig(), this will not affect the caching of the rest of your configuration data, and the closures would be cached in your opcode cache anyway. How does performance differ in constructing a factory class vs executing a closure? Does PHP wrap and instantiate closures only when you execute them, or would it do this for every

ZF2 widgets/views in layout

大憨熊 提交于 2020-01-17 14:01:35
问题 I am working on a website where I need a "widget" like view in my layout of Zend Framework 2. the widget should show the operational status of the server (this is done). (Correct me if this is bad MVC style) I have build a controller with the function viewStatusAction(){ ... return $viewModel(array($vars)) } then i want to use a viewHelper to get the status of the action. This is where I'm stuck. I know how to create the viewHelper, but not where to start to get the returned view from the

ZF2 widgets/views in layout

我与影子孤独终老i 提交于 2020-01-17 14:00:06
问题 I am working on a website where I need a "widget" like view in my layout of Zend Framework 2. the widget should show the operational status of the server (this is done). (Correct me if this is bad MVC style) I have build a controller with the function viewStatusAction(){ ... return $viewModel(array($vars)) } then i want to use a viewHelper to get the status of the action. This is where I'm stuck. I know how to create the viewHelper, but not where to start to get the returned view from the

zend 2: Automatically inject a template for all actions of a module without modifying site wide configuration

给你一囗甜甜゛ 提交于 2020-01-17 06:22:12
问题 I am using the Zend skeleton application. I want to have a sub menu bar (via a template) injected underneath the default site wide menu bar, but I don't want to modify the site wide app settings, I'd like to just have it in the module. Looking at examples it seems I would have to manually inject the menu bar template in each of my controller's actions and in every template where I want it to appear like this: public function indexAction() { $view = new ViewModel(); $subNavView = new ViewModel