zend-framework2

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

ZF2 Select element usage

那年仲夏 提交于 2020-01-17 04:48:04
问题 I'm using Zend Framework 2 and I need a Dependent Dropdown. When user select an category (cat_id on my example) the system fills the subcategory (sca_id) with the correct elements. I could do that by creating an application like this: My form looks like: $this->add(array( 'name' => 'cat_id', 'type' => 'Zend\Form\Element\Select', 'options' => array( 'label' => 'Categoria', 'value_options' => array( '' => '', ), ), )); $this->add(array( 'name' => 'sca_id', 'type' => 'Zend\Form\Element\Select',

creating mapped ORM Entities without the cli?

可紊 提交于 2020-01-17 03:59:09
问题 I'm working on an apiglity project that uses zend framework 2 and the doctrine. i included in local.config.php of my zf2 project the following code: return array( 'doctrine' => array( 'connection' => array( 'orm_default' => array( 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'params' => array( 'host' => 'localhost', 'port' => '3306', 'user' => '<username>', 'password' => '<password>', 'dbname' => '<db>', ) ) ) ), ); in my main module's configuration file (module.config.php) I

Zend Framework 2 - Set Template Path for Module

寵の児 提交于 2020-01-16 13:17:24
问题 I googled alot and couldn't come up with an answer... I'm using the tutorial-skeleton application. It automatically includes under 'view/album/album' the html files corresponding to my actions like add or index. I'm using a submodule and the standard loading won't find my html-files. I followed this guide for setting a custom template path. This works for the index because here I use a ViewModel instance. But my add/delete/edit actions just return an array like this one. Is there a way to

How to add File\MimeType Validator in Zend Framework 2 Model Declaration

孤人 提交于 2020-01-16 08:06:26
问题 Actually I'm developing a simple file uploader. In the ImageUploader.php file I define the getInputFilter function, all works unless I try to add a File\MimeType validator: <?php namespace Admin\Model; use Zend\InputFilter\Factory as InputFactory; use Zend\InputFilter\InputFilter; use Zend\InputFilter\InputFilterAwareInterface; use Zend\InputFilter\InputFilterInterface; use Zend\Validator\File\MimeType; //tried also with use Zend\Validator\File; [...] public function getInputFilter() { [...]

Zend Framework 2 Db: Make a part of the query negative using Predicate objects

一个人想着一个人 提交于 2020-01-16 04:50:07
问题 How do you negate a part of the query using Zend Framework 2? I'm trying to do the Zend\Db equivalent of this dynamic MySQL query-part: NOT (`a` = 1 AND `b`IS NULL AND `c` LIKE 'foo') Right now I have the three query-parts as Predicate objects (Operator, IsNull and Like objects) . How can I negate these and put in the where? Is it possible to convert a Predicate object (like an Operator or IsNull object) to a Sql String? 回答1: Zend dose not have a out of box solution for this , I wrote a class

php zend framework 2 routing with dynamic controller name but same controller

这一生的挚爱 提交于 2020-01-16 00:45:42
问题 i'm running into a routing beginners problem with zend framework 2: i want to make a routing that will work something like this: www.mysite.com/city/school/class with the routing i want to be able: www.mysite.com/chicago will take me to a city.phtml page with "chicago" as a parameter same with www.mysite.com/chicago/jcc will take me to a school.phtml with "jcc" as a parameter name and so on.. what i tried to do is: return array( 'router' => array( 'routes' => array( 'main' => array( 'type' =>

ZF2 - MySQL Regex for Whole word searches

巧了我就是萌 提交于 2020-01-15 12:14:15
问题 Given: You have a functioning substring-search in a ZF2 model. How do you do turn that into a whole-word search? 回答1: One method would be to use a MySQL REGEXP call in a Predicate Expression. Where $select is an instance of Zend\Db\Sql\Select and $searchFor is your search term: The original substring search might use a where like this... $select->where(array( new Predicate\PredicateSet( array( new Zend\Db\Sql\Predicate\Like('tag', '%' . $searchFor . '%'), new Zend\Db\Sql\Predicate\Like('title

I can't seem to get started with Zend Framework 2 skeleton app

▼魔方 西西 提交于 2020-01-15 12:11:54
问题 I'm following through the getting started skeleton app tutorial on the Zend homepage: http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html I've got as far as being able to enter into the browser address bar "zf2-tutorial.localhost/" and my Zend welcome page should appear. It doesn't, the apache web folder (/var/www) directory appears instead. If I enter "http://zf2-tutorial.localhost/1234" to test whether the Zend 404 page appears, it doesn't. The default apache Not

zend framework 2 and sqlserver driver issues

≡放荡痞女 提交于 2020-01-15 10:41:51
问题 when i try connecting to my sql server database from my zf2 application as shown below, return array( 'db' => array( 'driver' => 'Pdo', 'dsn' => 'sqlsrv:dbname=album;hostname=192.168.0.20', 'username' => 'user', 'password' => 'pass', 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' ), ), 'service_manager' => array( 'factories' => array( 'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory', ), ), ); I get this error, File: /usr/local/zend/apache2