zend-framework2

Publishing assets from modules in Zend Framework 2

谁说我不能喝 提交于 2019-12-05 05:25:21
问题 It is generally adviced to store module assets inside the module's directory, inside moduleName/public (or whatever you want to name the asset's directory). Zend Framework 2 unfortunately doesn't support asset publishing for module assets by default. According to MWOP , there was nothing planned ~1 month ago and I guess there still is no real plan (they had probably a lot of work to get the stable version ready). (But, some day, they are going to address this issue.) As my ZF2 app is growing

Zend Framework 2 default module

北城以北 提交于 2019-12-05 03:14:32
问题 In ZF1 you did not have to include the module in the URL; if it was not provided, it would default to... the default module. How can this be accomplished in ZF2? I have used the skeleton application to get up and running, but it seems as if I always need to include the module name, e.g. /application/controller/action . I figured I could work around this by creating a route with two "placeholders"; controller and action, and then set the default module to "application". I would then put this

How to use Apigility with an existing ZF2 application?

穿精又带淫゛_ 提交于 2019-12-05 02:56:39
I have a ZF2 Application with some modules. I would like to allow use my existing modules with Apigility, inside my application. I tried installing these modules with composer : "require": { "php": ">=5.3.3", "phpoffice/phpexcel":"*", "monolog/monolog" : "1.*", "zendframework/zend-developer-tools": "dev-master", "bjyoungblood/bjy-profiler": "dev-master", "radnan/rdn-router": "1.*", "bshaffer/oauth2-server-php": "dev-develop", "rwoverdijk/assetmanager": "~1.3", "zfcampus/zf-apigility": "~1.0-dev", "zfcampus/zf-apigility-provider": "~1.0-dev", "zfcampus/zf-apigility-documentation": "~1.0-dev",

MasterSlaveFeature How-To

早过忘川 提交于 2019-12-05 02:06:10
问题 I currently have my Db Models using AbstractTableGateway and all my select/insert/update/delete queries are working just fine. But now I would like to add the MasterSlaveFeature and I'm a bit confused on how to do this. The documentation doesn't exactly give a good example: http://zf2.readthedocs.org/en/latest/modules/zend.db.table-gateway.html#tablegateway-features I currently have this setup: namespace Login\Model; use Zend\Db\TableGateway\Feature\MasterSlaveFeature; use Zend\Db

ZF2 - what will be dispatched if router matches multiple routes?

那年仲夏 提交于 2019-12-05 02:05:01
So - what if I have a url that might be matched against many routes... which route will win? Which action will be dispatched? Is it simple- first defined - first dispatched? Here's routes for example: 'route-catchall' => array( 'type' => 'regex', 'options' => array( 'regex' => '/api/v1/.*', 'defaults' => array( 'controller' => 'IndexController', 'action' => 'apiCatchAll', ), ), ), 'route-test1' => array( 'type' => 'literal', 'options' => array( 'route' => '/api/v1/route1', 'defaults' => array( 'controller' => 'IndexController', 'action' => 'apiRoute1', ), ), ), Would this url example.com/api

Zend Framework 2 display a view within a view

匆匆过客 提交于 2019-12-05 01:13:05
问题 I have two modules Admin and Login. I want to display the Login view 'login.phtml' within the admin view 'index.html' I have the following in the Admin modules indexAction controller public function indexAction() { $login = new LoginController(); $view = new ViewModel(array( 'theloginform' => $login->loginAction(), )); return $view; } In the LoginAction method in the Login controller I return the ViewModel for the 'login.phtml' file. public function LoginAction() { $view = new ViewModel();

How to set filters and validators in ZF2 fieldsets using Zend\\Form\\Factory?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 01:05:23
I use Zend\Form\Factory to create forms in zend framework2 $factory = new Zend\Form\Factory(); $factory->createForm(array( 'elements' => array( array( 'spec' => array( 'name' => 'name', ), ), ), 'input_filter' => array( 'name' => array( 'validators' => array( // validators for field "name" ), 'filters' => array( // filters for field "name" ), ), ), )); You can see that there are filters and validators for field "name". It works. I have the problem if I use fieldsets: $factory->createForm(array( 'fieldsets' => array( array( 'spec' => array( 'name' => 'common', 'elements' => array( array( 'spec'

How to view db queries generated by TableGateway in Zend Framework 2

社会主义新天地 提交于 2019-12-05 00:54:25
问题 I am brand new to ZF2 and am trying to use a tableGateway to manage and update entries in a database. I am able to select and update items without a problem, but when inserting I get an error. Since the tableGateway class creates the query on the fly, how can I see the query itself? $this->tableGateway->insert($data); An error occurred during execution; please try again later. Additional information: Zend\Db\Adapter\Exception\InvalidQueryException File: /[redacted]/vendor/zendframework

ZF2 Use Redirect in outside of controller

一曲冷凌霜 提交于 2019-12-05 00:51:08
问题 I'm working on an ACL which is called in Module.php and attached to the bootstrap. Obviously the ACL restricts access to certain areas of the site, which brings the need for redirects. However, when trying to use the controller plugin for redirects it doesn't work as the plugin appears to require a controller. What's the best way to redirect outside from outside of a controller? The vanilla header() function is not suitable as I need to use defined routes. Any help would be great! Cheers- 回答1

Get local value in layout or view in Zend Framework 2

旧时模样 提交于 2019-12-04 23:59:51
问题 How can we get local value (i.e: 'en' or 'en_US', 'de' etc) in layout.phtml or views in Zend Framework 2? My local setting are exactly same as explained here <?php namespace FileManager; use Zend\Mvc\ModuleRouteListener; class Module { public function onBootstrap($e) { $translator = $e->getApplication()->getServiceManager()->get('translator'); $translator ->setLocale(\Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ->setFallbackLocale('en_US'); } //... } I want to get local value