未找到Silex \ Route :: setPath()

时间:2013-03-11 14:15:27

标签: php silex

我正在开发一个新的Silex项目,并且无法将路由安装到我的Controller提供商。我之前在另一个项目中成功完成了这项工作,但现在我在app.php中添加了以下路由:

$app->mount('/', new CommonController());
$app->mount('/feeds', new FeedsController());
$app->mount('/admin', new AdminController());

我收到致命错误:Fatal error: Call to undefined method Silex\Route::setPath() in [root]/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php on line 255

修改
挂载根路由时不会抛出错误。仅当我添加/feeds/admin结束编辑

我无法弄清楚这可能来自哪里 - 我已经在我的其他工作项目中搜索了这个函数定义,但是在代码中找不到它。我想我可能会错过composer.json中的一个库,但我不确定它可能是哪一个 - 两个项目的文件几乎相同:

WORKING composer.json:

{
    "name"        : "lyrixx/Silex-Kitchen-Edition",
    "type"        : "library",
    "description" : "A Silex Edition. This project is a base for your silex applications.",
    "keywords"    : ["framework"],
    "homepage"    : "http://lyrixx.github.com/Silex-Kitchen-Edition/",
    "license"     : "MIT",
    "authors"     : [
        {
            "name"  : "Grégoire Pineau",
            "email" : "lyrixx@lyrixx.info"
        }
    ],
    "repositories": [
        {
            "type": "package",
            "package": {
                "name"    : "twitter/bootstrap",
                "version" : "2.0.4",
                "source"  : {
                    "url"       : "https://github.com/twitter/bootstrap.git",
                    "type"      : "git",
                    "reference" : "v2.0.4"
                }
            }
        }
    ],
    "require": {
        "php"                     : ">=5.3.3",
        "silex/silex"             : "dev-master",
        "twig/twig"               : "1.*",
        "monolog/monolog"         : "1.0.*",
        "symfony/form"            : "2.1.*",
        "symfony/translation"     : "2.1.*",
        "symfony/twig-bridge"     : "2.1.*",
        "symfony/validator"       : "2.1.*",
        "symfony/yaml"            : "2.1.*",
        "symfony/config"          : "2.1.*",
        "kriswallsmith/assetic"   : "1.0.*",
        "twitter/bootstrap"       : "2.0.4",
        "doctrine/dbal"           : "2.2.*",
        "symfony/security"        : "2.1.*",
        "fate/silex-extensions"   : "dev-master",
        "michelf/php-markdown"    : "1.3.*@dev",
        "swiftmailer/swiftmailer" : ">=4.1.2,<4.2-dev"
    },
    "require-dev": {
        "symfony/dom-crawler"   : "2.1.*",
        "symfony/css-selector"  : "2.1.*",
        "symfony/browser-kit"   : "2.1.*"
    },
    "minimum-stability" : "dev",
    "scripts": {
        "post-install-cmd": "Lx\\Composer\\Script::postInstall"
    },
    "autoload": {
        "psr-0": {
            [autoload routes defined here]
        }
    }
}

“BROKEN”composer.json:

{
    "require": {
        "php"                     : ">=5.3.3",
        "silex/silex"             : "dev-master",
        "twig/twig"               : "1.*",
        "monolog/monolog"         : "1.0.*",
        "symfony/form"            : "2.1.*",
        "symfony/translation"     : "2.1.*",
        "symfony/twig-bridge"     : "2.1.*",
        "symfony/validator"       : "2.1.*",
        "symfony/yaml"            : "2.1.*",
        "symfony/config"          : "2.1.*",
        "kriswallsmith/assetic"   : "1.0.*",
        "twitter/bootstrap"       : "2.0.*",
        "doctrine/dbal"           : "2.2.*",
        "fate/silex-extensions"   : "dev-master",
        "swiftmailer/swiftmailer" : ">=4.1.2,<4.2-dev"
    },
    "autoload": {
        "psr-0": {
            [autoload routes defined here]
        }
    }
}

同样,这可能不是我问题的根本原因,只是我的直觉。任何人都可以破译这里发生的事情吗?

第二次编辑:FeedsController.php

<?php

namespace Controllers;

use Controllers\CommonController;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;

class FeedsController extends CommonController
{

    public function connect(Application $app)
    {
        $controller = $app['controllers_factory'];

        $controller->get('/', function (Request $request, Application $app)
        {
            return 'Yay!';
        });

        return $controller;
    }
}

1 个答案:

答案 0 :(得分:0)

我已将问题缩小到我的vendor文件夹中的一个坏库,但我无法确定它是哪一个。我将正确工作的供应商文件夹复制到我破损的文件夹中,一切都开始工作了。

一旦我知道确切的问题,我会更新这个答案。