首先,对于大多数人来说,如果我自己还没有做过一些研究,我也不会问这里,我看到很多类似的题目问题,但它们似乎与我所遇到的问题不同。 / p>
=实际开始=
所以我正在关注这个名为 Laravel 5.2 PHP构建社交网络的Web教程系列,我在第三集结束时陷入困境。我的问题是,当我尝试点击注册按钮时,出现此错误:
1/1
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 755
at Router->findRoute(object(Request)) in Router.php line 610
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
我尝试修复web.php
,welcome.blade.php
,UserController.php
任何人都可以帮我理解错误吗?
web.php
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
UserController.php
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function postSignUp(Request $request){
$email = $request['email'];
$first_name = $request['first_name'];
$password = bcrypt($request['password']);
$user = new User();
$user->email = $email;
$user->first_name = $first_name;
$user->password = $password;
$user->save();
return redirect()->back();
}
public function postSignIn(Request $request){
$email = $request['email'];
$password = $request['password'];
}
}
welcome.blade.php
@extends('layouts.master')
@section('title')
Welcome!
@endsection
@section('content')
<div class="row">
<div class="col-md-6">
<h3>Sign Up</h3>
<form action="{{route('signup')}}" method="POST">
<div class="form-group">
<label for="email">Your Email</label>
<input type="form-control" type="text" name="email" id="email">
</div>
<div class="form-group">
<label for="first_name">Your First Name</label>
<input type="form-control" type="text" name="first_name" id="first_name">
</div>
<div class="form-group">
<label for="password">Your Password</label>
<input type="form-control" type="password" name="password" id="password">
</div>
<button type="submit" class="btn btn-primary"> Submit</button>
<input type="hidden" name="_token" value="{{Session::token()}}">
</form>
</div>
<div class="col-md-6">
<h3>Sign In</h3>
<form action="#" method="post">
<div class="form-group">
<label for="email">Your Email</label>
<input type="form-control" type="text" name="email" id="email">
</div>
<div class="form-group">
<label for="password">Your Password</label>
<input type="form-control" type="password" name="password" id="password">
</div>
<button type="submit" class="btn btn-primary"> Submit</button>
</form>
</div>
</div>
@endsection
我跑的时候去吧:php artisan route:list
+--------+----------+----------+--------+------------------------------------------------+----------
----+
| Domain | Method | URI | Name | Action | Middlewar
e |
+--------+----------+----------+--------+------------------------------------------------+----------
----+
| | GET|HEAD | / | | Closure | web
|
| | GET|HEAD | api/user | | Closure | api,auth:
api |
| | POST | signup | signup | App\Http\Controllers\UserController@postSignUp | web
|
+--------+----------+----------+--------+------------------------------------------------+----------
----+
EDIT 11/21/2016 07:00 PM:值得注意的是,当我使用Laravel 5.3时,我不确定Presenter使用的是什么,但他使用的是一个 routes.php ,我只是尝试使用 web.php 来解决这个问题,因为它似乎与我需要遵循的教程最接近。我的链接也是 http://localhost/hiro/public/
答案 0 :(得分:0)
似乎路线本身并没有错。
这对我来说真的只是猜测,但值得一试:
<强> web.php 强>
from pyspark.sql.functions import when, col
df.withColumn("z", when(col("y").isNull(), 1).otherwise(0))
<强> welcome.blade.php 强>
<?php
// Removed a forward slash from the route
Route::post('signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
答案 1 :(得分:0)
这是您的服务器配置。
请在您的虚拟主机中使用/hiro/public
作为您的文档根目录。
或者将此添加到.htaccess文件中:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]