zend-framework-mvc

ServiceManager in ZF3

删除回忆录丶 提交于 2020-01-09 11:11:19
问题 I know that this has been covered extensively in other threads, but I'm struggling to work out how to replicate the effect of $this->getServiceLocator() from ZF2 controllers in ZF3 ones. I have tried creating a factory using the various other answers and tutorials that I've found here and elsewhere, but ended up in a mess with each of them, so I'm pasting my code as it was when I started in the hope that someone can point me in the right direction? From /module/Application/config/module

ServiceManager in ZF3

独自空忆成欢 提交于 2020-01-09 11:10:06
问题 I know that this has been covered extensively in other threads, but I'm struggling to work out how to replicate the effect of $this->getServiceLocator() from ZF2 controllers in ZF3 ones. I have tried creating a factory using the various other answers and tutorials that I've found here and elsewhere, but ended up in a mess with each of them, so I'm pasting my code as it was when I started in the hope that someone can point me in the right direction? From /module/Application/config/module

zend framework plug-in - predispatch()

你。 提交于 2019-12-25 04:57:46
问题 I wrote a plugin with predispatch() method to check access rights on each controller request . I have made plugin as : class My_Plugin_Checklogin extends Zend_Controller_Plugin_Abstract { public function preDispatch() { if (isset($_SESSION['Zend_Auth_Static'])) { //no login $request = $this->getRequest(); //the request $request->setModuleName('default'); $request->setControllerName('index'); $request->setActionName('index'); //send to default/login/index } } } It's calling predispatch()

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

点点圈 提交于 2019-12-24 17:09:33
问题 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 to a different page with a different layout. Here is the module.config.php <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework

ZF3 zend-mvc-skeleton internationalization not working

自古美人都是妖i 提交于 2019-12-22 06:38:04
问题 I'm trying to evaluate if it's already the right time to start moving to ZF3 (or keep developing my application with ZF2). Therefore, I installed the mvc-skeleton application and walked through the MVC tutorial (here) which worked perfectly until I got to the internationalization part. I installed the components (i.e. zend-i18n and zend-mvc-i18n component), created the translation files (i.e. en_US.mo and en_US.po) and copied them into my module/Application/language/ folder and added the

Zend_Auth best practices

这一生的挚爱 提交于 2019-12-18 17:33:20
问题 My goal is to require login for certain pages. I am using Zend Framework MVC, and I'm trying to find examples regarding best practices. Some notes on what I'm looking for: I want non-logged in users to get a login box, and then return to logged in version of the page, once authenticated I want to use dependency injection, and avoid singletons Small code footprint - tie into Zend mvc structure Should login box be a separate controller and do header redirect? How to return to landing page after

ZF2 - Get controller name into layout/views

删除回忆录丶 提交于 2019-12-17 07:26:49
问题 I know with ZF1 you would retrieve the module/controller name using custom View Helpers that would get the singleton frontController object and get the name there. Using ZF2 as they've abolished alot of the singleton nature of the framework and introduced DI where I've specified aliases for all of my controllers within this module... I can imagine I would get it through accessing the DI or perhaps injecting the current name into the layout. Anyone got any idea how you would do it. I guess

Loading message instead of timeout while executing a heavy query

偶尔善良 提交于 2019-12-14 00:03:58
问题 I'm running Zend server and ZF1 with db2 database. For some export, the queries take a very long time (>50 seconds) this causes a 408 timeout error. I'm looking for a solution to show a loading message on the client while running the SQL query. Any help is appreciated. 回答1: You need to increase the maximum execution time allowed for php so that it can finish and not be terminated with 408 return code. Either locally for that script only: http://php.net/manual/en/function.set-time-limit.php or

Zend_Test on Action_Helper accessing $bootstrap->getOptions() error

不想你离开。 提交于 2019-12-13 20:16:16
问题 I am accessing options from an action controller, which is working well with the application, but I've hit a problem when I attempt to UnitTest it: PHP Fatal error: Call to a member function getOptions() on a non-object in /home/zendtest/library/ZC/Action/Helper/Signup.php on line 43 For my tests I followed the setup from ZC at http://www.zendcasts.com/unit-testing-action-helpers/2010/11/ with source available here I added another test in tests/library/ZC/Action/Helper/SignupTest.php : public

ZF2: How to attach listener on the event in the Module class?

风格不统一 提交于 2019-12-13 06:45:34
问题 I want to set a basePath to be the same for every component of my Mvc for a given request. I mean when I call these methods I want to get the same result, lets say '/spam/ham/' : echo $this->headLink()->prependStylesheet($this->basePath() . '/styles.css') // $this->basePath() has to be '/spam/ham/' $this->getServiceLocator() ->get('viewhelpermanager') ->get('headLink') ->rependStylesheet($this->getRequest()->getBasePath() . '/styles.css') // $this->setRequest()->getBasePath() has to be /spam