我正在运行Manjaro linux,我已经安装了apache 2.4.10-1和php 5.5.15-1以及php-composer 1.0.0.alpha8.458-1.
我想用这个命令下载带有composer的项目
composer create-project nette/sandbox TaskManager
Run Code Online (Sandbox Code Playgroud)
但是我在使用ext-iconv时遇到错误
- nette/neon v2.2.1 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.
- nette/nette v2.2.0 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.
Run Code Online (Sandbox Code Playgroud)
但是在我的php.ini中我启用了iconv扩展
extension=iconv.so
.
.
[iconv]
iconv.input_encoding = ISO-8859-1
iconv.internal_encoding = ISO-8859-1
iconv.output_encoding = ISO-8859-1
Run Code Online (Sandbox Code Playgroud)
在我的PHP脚本中,我可以使用iconv函数,没有任何问题.
当我运行php -mi时,请在列表中查看iconv与其他模块
知道哪里可能有问题?
编辑:当我从cli运行php -i时,我得到了这个:
Configuration File (php.ini) Path => /etc/php
Loaded Configuration File => /etc/php/php.ini
Scan this dir …Run Code Online (Sandbox Code Playgroud) 在Nette Framework中定义新属性宏的最佳方法是什么?
此外,是否可以在配置文件中这样做?
我想为Latte模板引擎创建自己的过滤器.他们的文档中有一个示例,但没有描述如何在演示者中注册它.
<?php
$latte = new Latte\Engine;
$latte->addFilter('myFilter', function ($s) {
return someMagic($s)
});
?>
Run Code Online (Sandbox Code Playgroud)
我打赌将有简单的方法在演示者中获取Latte\Engine的实例,但我不确定如何.
我正在尝试在jquery中为几个日期选择器设置不同的选项.我的代码看起来像这样:
{foreach $cart->getItems() as $item}
{if $item->action->prereservation}
var disableDates = new Array();
{if $item->action->hasVariants()}
disableDates[{!$item->id}] = {$disabledDates[$item->action->id][$item->idVariant]};
{else}
disableDates[{!$item->id}] = {$disabledDates[$item->action->id]};
{/if}
if (disableDates[{!$item->id}].length !== 0) {
$(".datepicker_"+'{$item->id}').datepicker({
maxDate: new Date('{!$item->action->voucherTo|date: Y-m-d}'),
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
console.log(disableDates[{!$item->id}]) // result is undefined (but not for last iteration)
return [ disableDates[{!$item->id}].indexOf(string) == -1 ]
}
})
} else {
$(".datepicker_"+'{$item->id}').datepicker({
maxDate: new Date('{!$item->action->voucherTo|date: Y-m-d}'),
})
}
{/if}
{/foreach}
Run Code Online (Sandbox Code Playgroud)
但如果foreach中有多个项目,我的js控制台显示错误无法读取第一次迭代的未定义属性'indexOf',只有最后一次是好的.有人能帮帮我吗?
在我的代码我结合模板系统Latte和jquery.
这是我在浏览器中的最终代码:
var disableDates = new Array();
disableDates[777955] = ["2014-07-25","2014-07-26","2014-07-27","2014-07-28","2014-07-29","2014-07-30","2014-07-31"]; …Run Code Online (Sandbox Code Playgroud) 我有基于Nette框架的小应用程序.
我已经创建了constants.neon文件并将其添加到容器中.将有一些数据可以从演示者,模型,表格等获得.
如何访问中的值constants.neon?
我知道有一种方法,(new \Nette\Neon\Neon())->decode([NEON_FILE_PATH])但我不认为这是right way.我怀疑使用后,addConfig(...)在bootstrap.php从这些配置文件中的所有数据应可遍布系统.
<?php
// bootstrap.php
require __DIR__ . '/../vendor/autoload.php';
$configurator = new Nette\Configurator;
$configurator->setDebugMode(true); // enable for your remote IP
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()
->addDirectory(__DIR__)
->addDirectory(__DIR__ . '/../vendor/phpoffice/phpexcel')
->register();
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$configurator->addConfig(__DIR__ . '/config/constants.neon');
$container = $configurator->createContainer();
return $container;
Run Code Online (Sandbox Code Playgroud)
我的constants.neon档案:
constants:
DP_OPT = 'DP'
PP_OPT = 'PP'
DV_OPT = 'DV'
ZM_OPT = 'ZM'
TP_OPT = …Run Code Online (Sandbox Code Playgroud) 我想有一些类型的自动检查PHP Nette Framework的编码标准是否有这样的?Eclipse,Netbeans的独立应用程序或插件...例如,要检查Java代码,我使用Checkstyle.或者Checkstyle还能检查Nette吗?
我正在使用名为summernote的wysiwyg,我发送给服务器的值,我用HTML Purifier净化它.之后我将它保存到DB(mysql).然后我需要在wysiwyg中显示纯化的html,因此将其写为textarea值(textarea在js中与summernote链接).但它显示转义的html而不是格式化文本.编辑器正常工作,js控制台显示没有错误.
Javascript我用来初始化summernote
$('.summernote').summernote({
lang: 'cs-CZ',
height: 100,
airMode: true,
prettifyHtml: true
});
Run Code Online (Sandbox Code Playgroud)
这是wysiwyg的屏幕截图(在空中模式下,因此未显示工具),控制台检查其值.
所见即所得的拿铁模板:
<textarea name="{$key}" class="summernote form-control" >{$value->value|noescape}</textarea>
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 nette 2.1.2 中创建表单向导。我创建了自己的组件,可以在其中注入 nette 表单。然后在拿铁模板中将表单呈现为各个步骤。
但是,我想在当前步骤中对表单字段进行验证,然后再从这一步切换到另一个步骤。为此,我需要两件事:
你能帮我怎么做吗?
我为我们的 Nette web 项目开发了一个核心。核心作为库注入。虽然我希望能够在不注入的情况下测试和尝试核心项目的功能。所以我不得不单独添加启动核心项目所需的文件。这在尝试新功能时非常有用,但我不想在发布中包含这些文件(但仍然可以在 git 上共享,因此同事也可以尝试)。
是否有任何好的做法来处理这种情况?
我只找到了两个选项:
我将文本输入添加到表单中并添加一些规则.这些输入不是必需的,但如果我不填写这些字段,我会收到验证错误.
例:
$this->addText('operationID', 'Operation ID:')
->setAttribute('class', 'tf tf-w110px')
->addRule(Nutnet_Form::INTEGER, 'Operation ID must be integer');
Run Code Online (Sandbox Code Playgroud)
如何正确设置规则,接受未填充的operationID字段,而不是给出Operation ID must be integer错误?
使用conditions帮助,但不舒服.
Nette PHP框架是否适合在PHP中创建RESTful API(对于客户端JavaScript应用程序),我找不到合适的文档 IAuthenticator
SimpleAuthetication.我不得不问如何将已登录用户的名称输入Nette组件(SomethingControl.php).显然我不能这样做:
$identity = $this->getUser()->getIdentity();
if ($identity) $this->template->username = $identity->getData()['username'];
Run Code Online (Sandbox Code Playgroud)
所以我试过这个:
$this->template->username = $this->user
Run Code Online (Sandbox Code Playgroud)
但这也不起作用.
我正在使用Nette Framework,我有这个命令在起作用:
$id = is_array($id) ? implode(', ', $id) : $id;
$this->database->table('manufacturing')->where('id', $id)->update(array('trash' => '1'));
Run Code Online (Sandbox Code Playgroud)
当我在网格中选择4行并调用此操作来删除项目时,它将生成以下SQL代码:
UPDATE `manufacturing`
SET `trash`='1'
WHERE (`id` = '31, 32, 33, 34')
Run Code Online (Sandbox Code Playgroud)
但我需要这样的代码来更新所有行:
UPDATE `manufacturing`
SET `trash` = '1'
WHERE ((`id` = '31') OR (`id` = '32') OR (`id` = '33') OR (`id` = '34'));
Run Code Online (Sandbox Code Playgroud)
内爆功能可以吗?谢谢.
编辑:当我做这个:
$id = is_array($id) ? implode(' "OR" ', $id) : $id;
Run Code Online (Sandbox Code Playgroud)
它会这样做:
UPDATE `manufacturing`
SET `trash`='1'
WHERE (`id` = '31 \"OR\" 32 \"OR\" 33 \"OR\" 34')
Run Code Online (Sandbox Code Playgroud) nette ×13
php ×10
composer-php ×2
javascript ×2
jquery ×2
apache ×1
checkstyle ×1
components ×1
database ×1
forms ×1
git ×1
html ×1
htmlpurifier ×1
iconv ×1
implode ×1
latte ×1
mysql ×1
rest ×1
summernote ×1
username ×1
validation ×1
wizard ×1