我正在看一个我在Laravel 4中制作的项目,我有以下方法
return Redirect::route('home')
->withDomain($domain)
->withAvailable($available);
我知道他们会转换为
->with("domain",$domain)
->with("available",$available);
,我知道因为它已经习惯了。我在Jeffrey Way个视频中看过这个。但现在它不起作用,它承诺这些方法是未定义的。
如果我运行composer update
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework 4.0.x-dev
- Conclusion: don't install laravel/framework 4.0.x-dev
- Conclusion: don't install laravel/framework v4.0.10
- Conclusion: don't install laravel/framework v4.0.9
- Conclusion: don't install laravel/framework v4.0.8
- Conclusion: don't install laravel/framework v4.0.7
- Conclusion: don't install laravel/framework v4.0.6
- Conclusion: don't install laravel/framework v4.0.5
- Conclusion: don't install laravel/framework v4.0.4
- Conclusion: don't install laravel/framework v4.0.3
- Conclusion: don't install laravel/framework v4.0.2
- Conclusion: don't install laravel/framework v4.0.1
- Conclusion: don't install laravel/framework v4.0.0
- Installation request for way/database dev-master -> satisfiable by way/database[dev-master].
- Conclusion: don't install laravel/framework v4.0.0-BETA4
- Conclusion: don't install laravel/framework v4.0.0-BETA3
- way/database dev-master requires illuminate/validation 4.1.x -> satisfiable by laravel/framework[4.1.x-dev], illuminate/validation[4.1.x-dev, v4
.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4
.1.24, v4.1.3, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
- Can only install one of: laravel/framework[v4.0.0-BETA2, 4.1.x-dev].
- don't install illuminate/validation 4.1.x-dev|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.0|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.1|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.10|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.11|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.12|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.13|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.14|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.15|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.16|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.17|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.18|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.19|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.2|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.20|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.21|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.22|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.23|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.24|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.3|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.4|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.5|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.6|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.7|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.8|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/validation v4.1.9|don't install laravel/framework v4.0.0-BETA2
- Installation request for laravel/framework 4.0.* -> satisfiable by laravel/framework[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4
, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9].
我的composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"require": {
"laravel/framework": "4.0.*",
"way/generators": "dev-master",
"way/database": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/controllers/user/cart",
"app/controllers/user/order",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/lib/commands",
"app/lib/curl",
"app/lib/debug",
"app/lib"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
答案 0 :(得分:1)
即使Laravel 4.0为响应提供了withName()
。发生在你身上的事情至少是奇怪的。
打开文件:
vendor\laravel\framework\src\Illuminate\Http\RedirectResponse.php
并检查您是否有
/**
* Dynamically bind flash data in the session.
*
* @param string $method
* @param array $parameters
* @return void
*/
public function __call($method, $parameters)
{
if (starts_with($method, 'with'))
{
return $this->with(snake_case(substr($method, 4)), $parameters[0]);
}
throw new \BadMethodCallException("Method [$method] does not exist on Redirect.");
}
这是为with()
提供动态调用的代码,它是由Taylor于2013-10-03添加的。
如果您没有这部分代码,可能会出现Laravel源代码问题,请删除Laravel:
rm -rf vendor/laravel
再次安装:
composer update
或者您可以在其他任何事情之前进行更新,因为如果它是一个非常古老的项目,您可能只是没有下载它。