Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

时间:2014-09-30 16:14:33

标签: php symfony laravel

我是laravel的明显初学者,我对此有一个问题: Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

我不知道似乎是什么问题。每当我点击注册按钮时,该错误就会显示出来。这个错误的可能原因是什么?

AdminController.php:

<?php

class AdminController extends Basecontroller{

    public function index()
    {   
        return View::make('content.index');
    } 

    public function registration()
    {
        return View::make('content.registration');
    }

    public function registrationSave()
    {
        $input= Input::all();
        $rules = array('username'=>'required|unique:admin', 'name'=>'required|unique:admin', 'password'=>'required');
        $validate = Validator::make($input,$rules);
        if($validate->passes())
        {
            $password = $input['password'];
            $password = Hash::make($password);

            $user= new User();
            $user->username=$input['username'];
            $user->name=$input['name'];
            $user->password=$password;
            $user->save();

            return Redirect::to('registration');

        }
    }

}

routes.php文件:

    Route::get('/','AdminController@index');

// Admin Registration
Route::get('admin/registration','AdminController@registration');
Route::post('admin/registration','AdminController@registrationSave');

registration.blade.php:

   @extends('layouts.master')
   @section('content')
     {{ Form::open(['url'=>'admin/registrationSave']) }}
          <div>
          {{ Form::label('name','Name: ') }} 
          {{ Form::text('name','',['placeholder'=>'Name']) }}          
          </div>
          <div>      
          {{ Form::label('username','Username: ') }} 
          {{ Form::text('username','',['placeholder'=>'Username']) }}
          </div>
          <div>
          {{ Form::label('password','Password: ') }} 
          {{ Form::password('password','',['placeholder'=>'Password']) }}          
          </div>

          <div>
          {{ Form::submit('Register') }}
          </div>
       {{ Form::close() }}
@endsection  

1 个答案:

答案 0 :(得分:2)

{{ Form::open(['url'=>'admin/registrationSave']) }}

看起来您正在尝试将URL指向控制器的方法名称,而不是路由本身的URL。 get / post路由共享相同的实际URL,因此将该行更改为:

{{ Form::open(['url'=>'/admin/registration']) }}