zend-framework2

Zend Framework 2 without Vhost configuration

不问归期 提交于 2019-12-18 12:38:52
问题 I had finished my first web application using Zend Framework 2 and I'm about to put it online. But may web host doesn't allow me to change my vhost configuration! The .htaccess file is allowed. So my question is: How to set up my ZF2 app with only .htaccess files? 回答1: Assuming you have a standard ZF2 application based of the skeleton, then try creating a .htaccess file in the root with this in it: RewriteEngine On RewriteRule ^\.htaccess$ - [F] RewriteCond %{REQUEST_URI} ="" RewriteRule ^.*$

Sessions in ZF2

三世轮回 提交于 2019-12-18 11:36:01
问题 Could you tell me how to properly use sessions in ZF2? So far I have this code: "session" => [ "remember_me_seconds" => 2419200, "use_cookies" => true, "cookie_httponly" => true ] That's the session config I copied from some post here on stackoverflow. Now should I put this code into module.config.php in each module that uses sessions or in the Application module? public function onBootstrap(EventInterface $Event) { $Config = $Event->getApplication()->getServiceManager()->get('Configuration')

Zend framework 2 recommended way for error handling

十年热恋 提交于 2019-12-18 10:25:29
问题 I noticed that the Skeleton Application that Zend provides does not handle error 500 . I know that in ZF1 there was an ErrorController that took care of that. I have done some research online, but did not find a clear cut solution for this. So what is the best way for error handling in ZF2. Would it be on per module basis or some global exception/error handler? I know that another solution would be to add ini_set('display_errors', true); to my index.php , but I don't really like that solution

How to merge Zend Framework 2 module public directories

扶醉桌前 提交于 2019-12-18 03:04:41
问题 Some zf2 modules have public directories for distribution of resources such as js/css/images. What is best practice for making these resouces available to the applicaiton? I would like it so that these resources were automatically available through http://mysite.com/[moduleName]/ . For example, root/public/js/sitescript.js --> http:\\mysite.com\js\sitescript.js root/module/mymodule/public/js/modulescript.js --> http:\\mysite.com\mymodule\js\modulescript.js root/vendor/vendormodule/public/js

Zend Framework 2 - Form Element Decorators

会有一股神秘感。 提交于 2019-12-17 22:37:08
问题 I want to force the Zend form into Twitter Bootstrap style. I currently iterate through the form fields and write the form info into my bootstrap div construction. I saw in Zend Framework 1(!) that there is a way to do this within a decorator. But for some reason the doc for version 2 doesn't cover this point... I'd like to do something like this: protected $_format = '<label for="%s">%s</label>' . '<input id="%s" name="%s" type="text" value="%s"/>'; public function render($content) {

Install and configure mod_rewrite for Apache 2 on Mac OS X for Zend Framework 2

大城市里の小女人 提交于 2019-12-17 22:19:19
问题 I getting started with zend framework 2 and they have a prerequisite of an installation and configuration of mod_rewrite for apache. Apache 2.2.22 came pre-installed on Mac OS X 10.8.2. Is there an easy way to install and configure mod_rewrite for apache? The only help I have come across suggests to recompile apache. Is this the only way? 回答1: To check that mod_rewrite and PHP are enabled, look at /etc/apache2/httpd.conf and ensure that these lines: LoadModule rewrite_module libexec/apache2

Zend Framework 2 project example [closed]

こ雲淡風輕ζ 提交于 2019-12-17 22:14:25
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Can someone give me an Zend Framework 2 project example, or any info how to use zend_tool for ZF2. Thanks 回答1: Zend Framework 2 is under heavy development right now so there are no real examples yet. You can

Base Url of Zend Framework 2

拜拜、爱过 提交于 2019-12-17 20:59:09
问题 I would like to get Base URL in controller of Zend Framework 2 to pass as value of src attributes of img tag.I put my image in public folder. How can I get Base URL in controller of Zend Framework 2 ?? 回答1: You can use ServerUrl view helper for absolute URL's and BasePath for the relative ones in any view. $this->serverUrl(); // output: http://your.domain.com $this->serverUrl('/foo'); // output: http://your.domain.com/foo $this->basePath(); // output: / $this->basePath('img/bar.png'); //

How to translate form labels in Zend Framework 2?

白昼怎懂夜的黑 提交于 2019-12-17 19:36:17
问题 I'm not getting it!.. Can please someone explain, how to translate form labels? A simple example would be great. Thank you in advance! class Search\Form\CourseSearchForm ... class CourseSearchForm extends Form { ... public function __construct(array $cities) { parent::__construct('courseSearch'); ... $this->add(array( 'name' => 'city', 'type' => 'Zend\Form\Element\Select', 'options' => array( 'label' => 'Stadt', 'value_options' => $this->cities, 'id' => 'searchFormCity', ), )); ... } } view

Change layout in the controller of Zend Framework 2.0

ぃ、小莉子 提交于 2019-12-17 19:13:08
问题 I am learning ZF2.0 beta . In ZF1 we can change layout on the fly in controller: Zend_Layout::getMvcInstance()->setLayout('layoutname'); But in ZF2.0 Zend\Layout class doesn't has method getMvcInstance(). I think that it can be made using dependency injections but not sure. 回答1: The ZF2 is heavily under development and no guarantee can be made the way it works now, will be the way it works when ZF2 reaches a stable state. However, the new view layer from Zend\Mvc is recently merged so you