命名空间声明语句必须是Laravel-5中脚本中的第一个语句


Namespace declaration statement has to be the very first statement in the script in Laravel-5

在laravel中,我制作TrainingRequest文件以使用进行验证

php artisan make:request TrainingRequest
FatalErrorException in TrainingRequest.php line 3: 
Namespace declaration statement has to be the very first   statement  in the script 

我在创建的文件中进行验证,如下所示:-

<?php
namespace App'Http'Requests; <!--This is line number 3 -->
use App'Http'Requests'Request;
class TrainingRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
             return [
                'topic' =>  'required|min:3',
                'sub_topic'  =>  'required',
                'category'  =>  'required', 
            ];
    }
}

在我通过在控制器中创建对象来使用该类进行验证之后,我的控制器如下所示:-

<?php
 namespace App'Http'Controllers;
 use App'Training;
 use App'User;
 use App'Http'Requests;
 use App'Http'Controllers'Controller;
 use App'Http'Requests'TrainingRequest;
 use Request;

 class TrainingController extends Controller
{
public function store(TrainingRequest $request)
{
    //store Training
    //$training=Request::all();
    Training::create($request->all());
    return redirect('training');
}

在启动php标记之前有一个空格

解决方案只需清除空间