小编Kri*_*ris的帖子

Vagrant 403 Forbidden

我已经成功运行了Vagrant大约一个星期.昨晚我跑了流浪汉重装,现在我再也无法访问我的网站了.

我的文件位于/ vagrant/Sites.起初我的"欢迎页面"住在/ vagrant/Sites渲染

http://localhost:4567/ 
Run Code Online (Sandbox Code Playgroud)

我的所有项目都是站点下的文件夹.例如,/ vagrant/Sites/test不会呈现index.html.我得到以下内容

被禁止

您无权访问此服务器上的/.Apachehost/2.4.6(Ubuntu)服务器位于localhost端口4567

vhost看起来像:

<VirtualHost *:80>
  DocumentRoot "/vagrant/Sites/test"
  ServerName test
  <Directory "/vagrant/Sites/test">
    AllowOverride All
  </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

vhost由root拥有.我的项目文件归vagrant和chmod'ed 0777所有.

在没有成功之后,我做了一个完全的流浪汉破坏,随后流浪,然后localhost主机欢迎页面停止渲染以及禁止的错误.

apache2 vagrant

11
推荐指数
1
解决办法
2万
查看次数

通过Composer安装CakePHP插件和Helper

我想通过Composer安装以下插件和帮助器:

https://github.com/cakephp/debug_kit
https://github.com/loadsys/twitter-bootstrap-helper
Run Code Online (Sandbox Code Playgroud)

这是我的composer.json:

{
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "cakephp/debug_kit",
            "version": "2.0",
            "source": {
                "url": "https://github.com/cakephp/debug_kit",
                "type": "git",
                "reference": "origin/2.0"
            }
        }
    },
    {
        "type": "package",
        "package": {
            "name": "loadsys/twitter-bootstrap-helper",
            "version": "2.1",
            "source": {
                "url": "https://github.com/loadsys/twitter-bootstrap-helper",
                "type": "git",
                "reference": "origin/2.1"
            }
        }
    }
],
"require": {
    "loadsys/twitter-bootstrap-helper": "2.1.*",
    "cakephp/debug_kit": "2.0"
},
"config": {
    "vendor-dir": "Vendor/"
},
"autoload": {
    "psr-0": {
        "DebugKit": "/cakephp/debug_kit/",
        "TwitterBootstrap" : "/loadsys/twitter-bootstrap-helper"
    }
}
}
Run Code Online (Sandbox Code Playgroud)

这些包已成功安装在Vendor/cakephp/debug_kit和Vendor/loadsys/twitter-bootstrap-helper中

我的问题在于如何在CakePHP中加载它们.我的bootstrap.php中有以下内容:

require APP . 'Vendor/autoload.php'; 
Run Code Online (Sandbox Code Playgroud)

当我在要求自动加载后尝试加载插件时:

CakePlugin::load('DebugKit'); …
Run Code Online (Sandbox Code Playgroud)

cakephp cakephp-2.0 composer-php

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

CakePHP 3属于ToMany验证

我正在努力学习如何使用belongsToMany关系进行验证.即,经典的食谱/配料关系.我想要一个配方,在创建或编辑时始终有一个成分.我的RecipesTable中的验证结果如何?我试过了:

$validator->requirePresence('ingredients')->notEmpty('ingredients')
Run Code Online (Sandbox Code Playgroud)

以及

$validator->requirePresence('ingredients._ids')->notEmpty('ingredients._ids')
Run Code Online (Sandbox Code Playgroud)

第二个工作原理是我的表单不验证,但它不会将error类添加到输入中.我正在使用字段名称设置输入ingredients._ids.

我也无法创建要$this->post在我的测试中传递的数据,以便在我的测试中成功添加记录.我测试中的数据如下:

$data = [
    'ingredients' => [
        '_ids' => [
             '2'
        ]
    ];
Run Code Online (Sandbox Code Playgroud)

当然,我正在测试我的测试 $this->post('/recipes/add', $data);

我没有在测试中传递成分所需的规则.

validation cakephp model has-and-belongs-to-many cakephp-3.0

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