小编Mar*_*tyn的帖子

Zend_Rest_Route不适用于子目录控制器(例如admin/questions)

我正在尝试为子目录控制器定义RESTful路由.我希望能够为网址创建路由admin/questions/*.我的控制器是Admin_QuestionsController:

- application
  - controllers
    -Admin
      QuestionsController.php (class Admin_QuestionsController)
Run Code Online (Sandbox Code Playgroud)

下面是我为这个控制器声明我的RESTful路由的方法:

$restRoute = new Zend_Rest_Route($front, array(), array(
    'admin' => array('questions')
));
$router->addRoute('rest', $restRoute);
Run Code Online (Sandbox Code Playgroud)

..从文档中我看不出我做错了什么 - http://framework.zend.com/manual/1.12/en/zend.controller.router.html#zend.controller.router.routes.rest.但是,我收到以下错误:

Invalid controller specified (admin) 
Run Code Online (Sandbox Code Playgroud)

当我声明然后不是Rest路线时,我可以让路线工作:

$router->addRoute('admin_questions',
    new Zend_Controller_Router_Route( '/admin/questions', array(
        'controller' => 'Admin_Questions', 
        'action' => 'index')
    )
);
Run Code Online (Sandbox Code Playgroud)

..所以我认为我没有错误的文件夹结构,或类名.但是,我需要RESTful路线,这是我无法实现的.

php zend-framework

7
推荐指数
1
解决办法
201
查看次数

Gulp-sourcemaps没有创建源图文件?

我正在尝试使用Gulp源图来编写文件,但我无法在任何地方看到这些文件.如果在工作树中创建了任何新文件,我会看到它们git status,但没有任何新文件可以找到.

下面是我的gulpfile.js

var gulp = require('gulp'),
    sourcemaps = require('gulp-sourcemaps'),
    minify = require('gulp-minify'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify');

gulp.task('js', function() {

    return gulp.src('src/js/**/*.js')
        .pipe(sourcemaps.init())
            .pipe(concat('all.js'))
            .pipe(uglify())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./public/js'));
});
Run Code Online (Sandbox Code Playgroud)

这是正确的用法吗?从我在别处看到的例子来看,这应该没问题.我还看到这些插件可与源图混合:https://github.com/floridoo/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support

javascript gulp gulp-uglify

7
推荐指数
1
解决办法
4957
查看次数

PHPUnit测试double抛出PHPUnit_Framework_MockObject_BadMethodCallException

我正在尝试创建一个模拟对象,并在测试时在我的Zend框架应用程序中使用它:

public function testAskQuestionRouteWithLoggedIn()
{
    // get the mock auth object, and update the registry
    $auth = $this->getMockBuilder('QA_Auth')
        ->disableOriginalConstructor()
        ->getMock();

    // mock methods, and return values
    $auth->method('isAuthenticated')
        ->will( $this->returnValue( true ) );

    // update the registry
    $auth = Zend_Registry::set('Auth', $auth);

    // now preform the test as a logged in user
    $this->dispatch('/ask');
    $this->assertController('questions');
    $this->assertAction('new');

    // // // check the page contains a question form
    $this->assertQueryCount('form#questionForm', 1);
}
Run Code Online (Sandbox Code Playgroud)

...但是它抛出了一个PHPUnit_Framework_MockObject_BadMethodCallException异常,但实际上并没有多少(例如原因).如果我echo get_class($auth); exit;在我的应用程序中执行一个操作,我可以看到它是Mock_QA_Auth_f4627b7b类的,所以至少它正在拾取模拟实例.但是当我调用isAuthenticated方法时,它会抛出异常.我究竟做错了什么?

这是我看到的错误消息:

$ ./vendor/bin/phpunit tests/application/controllers/QuestionsControllerTest.php 
PHPUnit 4.4.2 by …
Run Code Online (Sandbox Code Playgroud)

php phpunit zend-framework

6
推荐指数
1
解决办法
2180
查看次数

`mvn package` 给出致命错误编译:无效标志:-parameters 错误

我已经使用 Initialzr 工具生成了一个 Spring Boot 项目。我已经按照本教程添加了模板和控制器:

https://www.baeldung.com/spring-boot-start

现在我只是想运行,mvn clean package但只是在我的命令提示符中看到以下错误:

...
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.501 s
[INFO] Finished at: 2019-06-17T11:03:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp: Fatal error compiling: invalid flag: -parameters -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For …
Run Code Online (Sandbox Code Playgroud)

java maven spring-boot

6
推荐指数
1
解决办法
2566
查看次数

CKEditor:如何隐藏拼写检查按钮

我一直无情地删除按钮/插件,但我找不到如何删除拼写检查按钮.我已设法删除SCAYT插件,以便不再显示但拼写检查按钮不会让步:

CKEDITOR.editorConfig = function( config ) {
    config.resize_enabled = false;
    config.removeButtons = 'Cut,Copy,Paste,PasteText,PasteFromWord,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript,addFile,Image,Table,Styles,Format,Maximize,HorizontalRule,Unlink,Blockquote,Indent,Outdent,RemoveFormat,Source,Spell';
    config.removePlugins = 'about,specialchar,scayt,spellchecker,elementspath,resize';
};
Run Code Online (Sandbox Code Playgroud)

我还尝试添加各种拼写变体来删除按钮,例如拼写检查,拼写检查,拼写等.我需要设置什么?

javascript ckeditor

5
推荐指数
1
解决办法
2970
查看次数

如何在Laravel之外使用Eloquent ORM的getQueryLog()?

我一直试图找出一种方法来记录我在Zend Framework 1中使用的Eloquent ORM的SQL查询.我遇到了以这种方式调用的getQueryLog()方法:

$queries = DB::getQueryLog();
Run Code Online (Sandbox Code Playgroud)

我发现Illuminate\Database\Connection包含getQueryLog()方法,所以我尝试执行以下操作:

use Illuminate\Database\Connection as DB;

class IndexController
{
    .
    .
    .
    public function indexAction()
    {
        // do stuff (e.g. fetch/update/create rows) 
        $questions = Questions::all()
        .
        .
        $queries = DB::getQueryLog();
        var_dump($queries); exit;
        .
        // render view
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,我得到以下通知,它返回NULL: Notice: Undefined property: IndexController::$queryLog in /var/www/qasystem/vendor/illuminate/database/Illuminate/Database/Connection.php on line 918 NULL

有人可以建议我如何在Laravel之外使用它吗?我在网上搜索过,看不到我需要做的任何事情,尽管我怀疑大多数例子都会在Laravel中使用.另外,Illuminate\Database\Connection是正确的类吗?谢谢

php laravel eloquent

5
推荐指数
1
解决办法
1852
查看次数

如何使用Twig模板自动检查复选框?

我想自动检查HTML中的复选框.我设法让这个工作,但它在模板中有点混乱:

<ul>
    {% for tag in tags %}
        {% set selected = false %}
        {% for article_tag in article.tags %}
            {% if article_tag.id == tag.id %}
                {% set selected = true %}
            {% endif %}
        {% endfor %}
        <li><input type="checkbox" name="tags[]" value="{{ tag.id }}" {% if selected %}checked{% endif %}> {{ tag.name }}</li>
    {% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)

所以我加载的数据是这样的(采用JSON格式):

[
    'tags' => [
        {'id'=> 1, 'name'=>'Travel'},
        {'id'=> 2, 'name'=>'Cooking'},
    ],
    'article' => {
        'tags' => [
            {'id'=> 1, 'name'=>'Travel'},
        ],
    } …
Run Code Online (Sandbox Code Playgroud)

php twig

5
推荐指数
1
解决办法
2469
查看次数

使用 .htaccess 仅授予对一个目录的访问权限

我只想提供对单个目录 (/dist) 的公共访问。我有一个 .htaccess 文件,其中包含以下内容:

Order deny,allow
Deny from all

<Directory /dist>
    Order Allow,Deny
    Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

我尝试首先拒绝所有内容的访问,然后使用 /dist 目录的允许规则覆盖该指令。但是,当我尝试通过浏览器访问任何文件时,我得到以下信息:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

.htaccess

5
推荐指数
1
解决办法
2042
查看次数

当PHP内置服务器崩溃时,端口仍在使用中

我正在使用 PHP 内置服务器,如下所示:

$ composer serve
> php -S localhost:8000 -t public/
Run Code Online (Sandbox Code Playgroud)

但超时了..?

[Symfony\Component\Process\Exception\ProcessTimedOutException]                     
  The process "php -S localhost:8080 -t public/" exceeded the timeout of 300 seconds.
Run Code Online (Sandbox Code Playgroud)

所以,我尝试再次启动它:

$ composer serve
> php -S localhost:8000 -t public/
[Thu May 26 21:31:51 2016] Failed to listen on localhost:8000 (reason: Address already in use)
Script php -S localhost:8000 -t public/ handling the serve event returned with error code 1
Run Code Online (Sandbox Code Playgroud)

为什么超时之前服务器运行的同一端口仍在使用中?我可以停止服务器内置的所有 PHP 实例吗?

如果重要的话,下面是我的composer.json 文件:

{
    .
    .
    .
    "scripts": {
        "serve": "php …
Run Code Online (Sandbox Code Playgroud)

php composer-php php-builtin-server

4
推荐指数
2
解决办法
3390
查看次数

如何在 Vue 3 中访问应用程序数据属性

我目前正在迁移到 Vue 3,我曾经能够访问旧 vue 2 应用程序中的属性,如下所示:

import { createApp } from 'vue/dist/vue.esm-bundler';
...

const app = createApp({
  // el: 'app', // removed
  data() {
    const results = ...;

    return {
      results,
      ...
    };
  },
  ...
});

// added for vue 3
app.mount('app')

const { results } = app

console.log(results) // is undefined
Run Code Online (Sandbox Code Playgroud)

..但现在我不能,并且检查应用程序对象时我无法找到数据属性。另外,我很好奇这是否已经改变以及最佳实践。

该应用程序正在页面上呈现,但我还需要访问应用程序的属性以获取其他内容,但我无法这样做。

vue.js vuejs3

4
推荐指数
1
解决办法
1036
查看次数