zend-framework-mvc

Zend_Auth best practices

本秂侑毒 提交于 2019-11-30 14:47:43
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 auth success? An idea to simply call the login controller action to display the login box in the

Zend Framework: Controller Plugins vs Action Helpers

痞子三分冷 提交于 2019-11-28 18:17:32
Could someone give few tips and/or examples how Controller Plugins and Action Helpers are different? Are there situations where particular task could be accomplished with one but not another? For me they both look more or less the same and I'm often having trouble having to decide when to use what... Are there any big differences? Controller plugins can hook into any controller at any point in the routing process (preDispatch postDispatch, routeStartup, routeShutdown) which makes them apt at providing behind the scenes functionality like ACL enforcement. Action Helpers are for for reusable but

Loading Modules Dynamically in Zend Framework 2

你。 提交于 2019-11-28 12:49:17
I have asked this question yesterday as well, but this one includes code. Issue My application have multiple modules and 2 types of user accounts, Some modules are loaded always which are present in application.config.php some of them are conditional i.e. some are loaded for user type A and some for user type B After going through documentations and questions on Stack Overflow, I understand some of ModuleManager functionalities and started implementing the logic that I though might work. Some how I figured out a way to load the modules that are not present in application.config.php [SUCCESS]

ZF2: Get url parameters in controller

独自空忆成欢 提交于 2019-11-28 05:22:11
I have experienced Zend Framework 1 and I've build some apps with that framework. Now, I'm experimenting Zend Framework 2, but I'm stuck on the url parameters. I've setup my routing like this: // Setup for router and routes 'Zend\Mvc\Router\RouteStack' => array( 'parameters' => array( 'routes' => array( 'default' => array( 'type' => 'Zend\Mvc\Router\Http\Segment', 'options' => array( 'route' => '/[:slug]', 'constraints' => array( 'slug' => '[a-zA-Z][a-zA-Z0-9_\/-]*' ), 'defaults' => array( 'controller' => 'Htmlsite\Controller\BootController', 'action' => 'index', 'slug' => 'home' ), ), ),

Zend Framework: Controller Plugins vs Action Helpers

时光怂恿深爱的人放手 提交于 2019-11-27 11:12:34
问题 Could someone give few tips and/or examples how Controller Plugins and Action Helpers are different? Are there situations where particular task could be accomplished with one but not another? For me they both look more or less the same and I'm often having trouble having to decide when to use what... Are there any big differences? 回答1: Controller plugins can hook into any controller at any point in the routing process (preDispatch postDispatch, routeStartup, routeShutdown) which makes them

Loading Modules Dynamically in Zend Framework 2

这一生的挚爱 提交于 2019-11-27 07:15:23
问题 I have asked this question yesterday as well, but this one includes code. Issue My application have multiple modules and 2 types of user accounts, Some modules are loaded always which are present in application.config.php some of them are conditional i.e. some are loaded for user type A and some for user type B After going through documentations and questions on Stack Overflow, I understand some of ModuleManager functionalities and started implementing the logic that I though might work. Some

ZF2: Get url parameters in controller

旧时模样 提交于 2019-11-27 05:33:46
问题 I have experienced Zend Framework 1 and I've build some apps with that framework. Now, I'm experimenting Zend Framework 2, but I'm stuck on the url parameters. I've setup my routing like this: // Setup for router and routes 'Zend\Mvc\Router\RouteStack' => array( 'parameters' => array( 'routes' => array( 'default' => array( 'type' => 'Zend\Mvc\Router\Http\Segment', 'options' => array( 'route' => '/[:slug]', 'constraints' => array( 'slug' => '[a-zA-Z][a-zA-Z0-9_\/-]*' ), 'defaults' => array(

ZF2 - Get controller name into layout/views

心已入冬 提交于 2019-11-27 04:25:15
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 there a hundred different ways but after sniffing about the code for a few hours I can't really figure out

How to render ZF2 view within JSON response?

旧时模样 提交于 2019-11-27 03:28:20
So far, I have figured out how to return a typical JSON response in Zend Framework 2. First, I added the ViewJsonStrategy to the strategies section of the view_manager configuration. Then, instead of returning a ViewModel instance from the controller action, I return a JsonModel instance with all my variables set. Now that I've figured that piece out, I need to understand how to render a view and return it within that JSON response. In ZF1, I was able to use $this->view->render($scriptName) , which returned the HTML as a string. In ZF2, the Zend\View\View::render(...) method returns void . So.

How to render ZF2 view within JSON response?

倖福魔咒の 提交于 2019-11-26 12:39:36
问题 So far, I have figured out how to return a typical JSON response in Zend Framework 2. First, I added the ViewJsonStrategy to the strategies section of the view_manager configuration. Then, instead of returning a ViewModel instance from the controller action, I return a JsonModel instance with all my variables set. Now that I\'ve figured that piece out, I need to understand how to render a view and return it within that JSON response. In ZF1, I was able to use $this->view->render($scriptName)