我创建了一个名为'currency'的新模块,并在module.config中配置了路由.它工作正常.之后我添加了一个名为CrateController的新控制器,用于货币汇率.还创建了表单,模型和视图文件.但它没有正确路由.
错误:
致命错误:未捕获的异常"的Zend \查看\异常\ RuntimeException的"有消息"的Zend \查看\渲染器\ PhpRenderer ::渲染:无法呈现模板'货币/箱/指数’; 解析器无法解析为文件....
任何线索来检查这将是有帮助的.
我的module.config文件如下.
return array(
'controllers' => array(
'invokables' => array(
'Currency\Controller\Currency' => 'Currency\Controller\CurrencyController',
'Currency\Controller\Crate' => 'Currency\Controller\CrateController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'currency' => array(
'type' => 'segment',
'options' => array(
'route' => '/currency[/:action][/:currency_id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'currency_id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Currency\Controller\Currency',
'action' => 'index',
),
),
), …Run Code Online (Sandbox Code Playgroud) 有没有办法在Zend Framework2中使用zend子表单.当我在互联网上进行搜索时,我已经找到了许多示例,展示了如何使用zend子表但使用Zend Framework1.
如果某人有一个链接/示例,其中一个人可以通过一个基本的例子,将是伟大的.
任何信息表示赞赏.
我正在使用带有Bootstrap和ReverseForm适配器的Zend框架,并且有一个有趣的问题:当我在Zend Form中使用Bootstrap Datepicker时,我有下一个异常:
Object provided to Escape helper, but flags do not allow recursion
有我的形式代码:
use \Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use \Zend\Form\Annotation as ZFA;
Run Code Online (Sandbox Code Playgroud)
...
/**
* @var \DateTime
*
* @ODM\Date
*
* @ZFA\Type("ReverseForm\Element\BootstrapDatepicker")
* @ZFA\Attributes({"type":"text"})
* @ZFA\Options({
* "label":"Date",
* "extended": {
* "help": {"content": ""},
* }
* })
*
*/
private $date;
Run Code Online (Sandbox Code Playgroud)
并有我的反向形式配置:
'ReverseForm\Element\BootstrapDatepicker' => array(
'js' => array(
'/vendor/datepicker/js/bootstrap-datepicker.js'
),
'css' => array(
'/vendor/datepicker/css/datepicker.css'
),
'template' => 'input.phtml',
'inlineJs' => "$('#%1\$s').datepicker(%2\$s);",
'inlineJsConfig' => array(
'format' => …Run Code Online (Sandbox Code Playgroud) 上传Zend\Db\Adapter\Exception\RuntimeException文件
\library\Zend\Db\Adapter\Driver\Pdo\Result.php:159
Run Code Online (Sandbox Code Playgroud)
我的数据库设置代码是
array(
'db' => array(
'driver' => 'Pdo',
'pdodriver' => 'mysql',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
'buffer_results' => true
),
'username' => 'root',
'password' => '',
'host' => 'localhost',
'dbname' => 'db_name',
),
)
Run Code Online (Sandbox Code Playgroud)
结果提取代码是
$statement = $this->sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
Run Code Online (Sandbox Code Playgroud)
我试过$results->buffer();&& $results->rewind()
我的迭代代码就像
foreach ( $results as $result ){
// code goes here ..
}
....
foreach ( $results as $result ){
// code goes here ..
}
Run Code Online (Sandbox Code Playgroud) 我正在研究ZF2项目,我的目录中有一些模块:
/module/module1
/module/module2
/module/module3
/module/module4
[...]
Run Code Online (Sandbox Code Playgroud)
但是,在每个模块中我也分别有一个特定的布局:
/module/module1/view/layout/layout.phtml
/module/module2/view/layout/layout.phtml
/module/module3/view/layout/layout.phtml
/module/module4/view/layout/layout.phtml
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何为我的所有模块设置通用布局,而不必在需要时修改每个布局.
谢谢
e:刚刚意识到这可能与SQL Server的事实有关.有人知道ZF2相当于SQL Server的LIMIT吗?
嗨,大家好,
一如既往地坚持使用ZF2.
我在一个类中有一个fetchAll()方法,它从某个表中选择行.现在,该方法有效,但我似乎无法限制它.
这工作(并以正确的顺序返回行):
public function fetchAll()
{
$resultSet = $this->tableGateway->select(function(Select $select){
$select->order('messageId ASC');
});
return $resultSet;
}
Run Code Online (Sandbox Code Playgroud)
但根据我的理解,限制应该相当容易(和类似),所以我这样做(这不起作用):
public function fetchAll()
{
$resultSet = $this->tableGateway->select(function(Select $select){
$select->limit(30);
});
return $resultSet;
}
Run Code Online (Sandbox Code Playgroud)
它现在没有返回任何东西.我究竟做错了什么?
我正在开始一个新项目.
我正在使用ZF2.我刚安装它并启动并运行Skeleton应用程序.
这是我的部署过程:
我试图在博客等处查看堆栈,zend网站和谷歌,但仍然没有任何真正的理解或解决我的问题.
我希望应用程序根据其环境使用不同的数据库凭据.例如,如果在我的本地计算机'dev'上,则使用凭据A,但如果在实时服务器上,则使用凭据B.
我已经阅读了很多关于全局和本地自动加载配置文件等的内容,但是请记住我的github repo是公共的,任何我提交任何配置文件的地方都会显示我的数据库详细信息.
我想知道是否有办法,相同的理论,全局和本地文件与数据库连接,我手动上传生产细节,而不是通过git出于安全原因,并告诉git以某种方式忽略本地配置文件?我还需要知道如何告诉应用程序根据环境和位置使用这些配置文件.
我有这个:
$this->redirect()->toRoute(
'edit_person',
array(
'controller' => 'person',
'action' => 'edit',
'id' => 1,
'bla' => '1'
)
);
Run Code Online (Sandbox Code Playgroud)
我想最终得到这个网址:
person/1/edit?bla=1
Run Code Online (Sandbox Code Playgroud)
换句话说,转换:
'bla' => '1'
Run Code Online (Sandbox Code Playgroud)
至
?bla=1
Run Code Online (Sandbox Code Playgroud)
而不是标准参数.可能吗?
我的zend框架2项目涉及一个在线餐厅菜单,我正在尝试制作一个表单来将Pizzas添加到数据库中.但是我的代码有问题.表单不会显示,而是出现此错误:
在表单中找不到[pizza_name]名称的元素
请帮我查一下我的代码有什么问题.
这是我的文件:
addPizzaForm.php:
<?php
namespace Pizza\Form;
use Zend\Form\Form;
use Pizza\Form\AddPizzaForm;
use Pizza\Model\Pizza;
class AddPizzaForm extends Form
{
public function construct() {
parent:: construct('addpizzaform');
$this->add(array(
'name' => 'pizza_name',
'type' => 'text',
'options' => array(label => 'Pizza name')));
$this->add(array(
'name' => 'ingredients',
'type' => 'textarea',
'options' => array(label => 'Ingredients')));
$this->add(array(
'name' => 'small_price',
'type' => 'text',
'options' => array(label => 'Small price')));
$this->add(array(
'name' => 'big_price',
'type' => 'text',
'options' => array(label => 'Big price')));
$this->add(array(
'name' => 'family_price', …Run Code Online (Sandbox Code Playgroud) 我试图为2个不同的模块使用相同的路由名称,是否可能?
模块用户:
/*Module.config.php*/
'dashboard' => array(
'type' => 'segment',
'options' => array(
'route' => '/dashboard',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Users\Controller\Users',
'action' => 'dashboard',
),
),
),
Run Code Online (Sandbox Code Playgroud)
模块管理员:
/*Module.config.php*/
'dashboard' => array(
'type' => 'segment',
'options' => array(
'route' => '/dashboard',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Admin\Controller\Admin',
'action' => 'dashboard',
),
),
),
Run Code Online (Sandbox Code Playgroud)
虽然我正在为仪表板创建2个不同的模块,但我只加载任何一个动作.
我怎样才能做到这一点?
zend-framework2 ×10
php ×6
zend-route ×2
annotations ×1
git ×1
layout ×1
parameters ×1
sql ×1
subforms ×1
zend-form ×1
zend-router ×1