我遇到了在laravel 4中我的UserController中发送密码请求的某个功能的问题.它会检查数据库中是否存在该电子邮件,然后如果用户这样做则发送电子邮件.然后,该函数在表中创建一个令牌,并在电子邮件中的链接末尾发送该令牌.
该函数用于在数据库中创建令牌,但它似乎有问题,因为我不断收到最大执行时间错误.我不知道造成这种情况的原因,似乎与重定向有关.有人可以帮帮我吗?提前致谢!
这是控制器功能:
public function passwordRequest() { $data = [ "requested"=>Input::old("requested") ]; if(Input::server("REQUEST_METHOD") == "POST") { $input = Input::all(); $rules = [ "email" => "required|exists:users,email" ]; $v = Validator::make($input,$rules); if($v->passes()) { $credentials = [ "email" => Input::get("email"),]; Password::remind($credentials,function($message,$user) { $message->from("request@test.com"); }); $data["requested"] = true; return Redirect::route("user/request")->with($data); } return Redirect::to(URL::route("user/request"))->withInput($data)->withErrors($v); } return View::make("user/request",$data); }
Route::group(["before"=>"guest"],function() { Route::any("/",[ "as"=>"user/login","uses"=>"UserController@userLogin" ]); Route::any("/request",[ "as"=>"user/request","uses"=>"UserController@passwordRequest" ]); Route::any("/reset",[ "as"=>"user/reset","uses"=>"UserController@passwordReset" ]); Route::any("/register",[ "as" => "user/register","uses" => "UserController@userRegister" ]); }) ;
如果需要,这是视图:
@extends("layouts.master") @section("content") <h1>Request Password Reset</h1> {{ Form::open([ "route"=>"user/request","autocomplete"=>"off" ]) }} @if(isset($errors)) @foreach ($errors->all() as $error) <div class="error"> <li>{{ $error }}</li> </div> @endforeach @endif @if(Session::has("requested")) <div class="success"> <li>An email has been sent with your password reset request.</li> </div> {{ Session::forget('requested') }} @endif <br /> {{ Form::label("email","Email:") }} {{ Form::text("email",Input::old("email"),[ "placeholder"=>"Email Address" ]) }} {{ Form::submit("Reset") }} {{ Form::close() }} <br /> {{ HTML::linkRoute("user/login","Return to Login") }} @stop
你的脚本执行超过30秒并被终止,与Laravel无关,但与PHP无关.默认限制为30秒,存储在PHP.ini文件中.要暂时延长时间限制,您可以在当前脚本中使用以下行代码,但也尝试优化脚本(如果可能)
set_time_limit(60); //60 seconds = 1 minute
You can do set_time_limit(0); so that the script will run forever –
however this is not recommended and your web server might catch you
out with an imposed HTTP timeout (usually around 5 minutes).
你也可以使用
ini_set('max_execution_time',60);