[英]Silex\Route::setPath() not found
I'm working on a new Silex project and am having trouble mounting a route to my Controller providers. 我正在研究一个新的Silex项目,无法安装通往我的Controller提供商的路由。 I have successfully done this before in another project, but now when I put the following routes in app.php
: 我之前已经在另一个项目中成功完成了此操作,但是现在当我将以下路由放入app.php
:
$app->mount('/', new CommonController());
$app->mount('/feeds', new FeedsController());
$app->mount('/admin', new AdminController());
I receive a fatal error: Fatal error: Call to undefined method Silex\\Route::setPath() in [root]/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php on line 255
我收到致命错误: Fatal error: Call to undefined method Silex\\Route::setPath() in [root]/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php on line 255
EDIT: 编辑:
The error does not get thrown when I mount the root route. 安装根路由时不会引发错误。 Only when I add /feeds
or /admin
. 仅当我添加/feeds
或/admin
。
END EDIT 结束编辑
I can't figure out where this might be coming from - I've searched my other working project for this function definition, but it's nowhere to be found in the code. 我不知道这可能来自哪里-我在其他工作项目中搜索了此函数定义,但是在代码中找不到它。 I think I might be missing a library in composer.json
but I'm not sure which one it might be - the file is almost identical across both projects: 我想我可能在composer.json
缺少一个库,但是我不确定它可能是哪个库-两个项目中的文件几乎相同:
WORKING composer.json: 工作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: “ 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]
}
}
}
Again, this may not even be the root cause of my issue, just my gut feeling. 同样,这可能甚至不是我的问题的根本原因,只是我的直觉。 Can anyone decipher what's going on here? 任何人都可以破译这里发生了什么吗?
SECOND EDIT: FeedsController.php 第二编辑: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;
}
}
I've narrowed the problem down to a bad library in my vendors folder, though I can't be sure which one it is. 我已经将问题缩小到我的供应商文件夹中的一个错误的库中,尽管我不确定是哪个。 I copied my correctly working vendors folder to my broken one and everything started working. 我将正常工作的vendors文件夹复制到损坏的文件夹中,一切开始正常工作。
I will update this answer once I know what the exact issue was. 一旦知道确切的问题是什么,我将更新此答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.