我正在尝试用React制作Laravel应用程序。我想从注册和授权表单开始。所以我用拉威尔的命令做了这些
作曲家需要laravel/ui
PHP工匠ui反应
PHP工匠ui反应--auth
但不幸的是,smth出错了,当我使用登录时,主页的路由不起作用。问题出在哪里?
应用程序\Http\控制器\Auth\登录
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
应用程序\控制器\家庭控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
应用程序/提供商/路由服务提供商
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
// public const MAIN = '/main';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}
视图\主页
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Dashboard') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
{{ __('You are logged in!') }}
</div>
</div>
</div>
</div>
</div>
@endsection
路由\web
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| 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');
});
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
//Route::get('/main', [App\Http\Controllers\HomeController::class, 'main'])->name('main');
路由\api
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
视图\auth\login
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
您可以尝试在应用程序/提供商/RouteServiceProvider中取消注释此行
// protected $namespace = 'App\\Http\\Controllers';
那个认证脚手架在拉威尔8中得到了复制
现在您可以使用其他选项进行身份验证。但是当你试图建造独立的水疗中心时,设防将是最好的选择https://laravel.com/docs/8.x/fortify#when-should-i-use-fortify
我已经编写了一个服务器-客户端(两个程序)结构,它工作正常。。。仅当使用TCP时。我的想法是使用TCP进行文本聊天传输(udp不可靠),但使用udp进行游戏数据包传输(是的,这是一种每秒30帧的动作游戏,所以我需要udp)。 但是,当我在客户端进程中与TCP建立连接时,我开始向服务器程序发送UDP数据包,并从服务器程序接收UDP数据包。客户端在单个线程中使用非阻塞套接字、UDP和TCP。这里没有多
我需要从同一个套接字或者从$*IN中读取多个线程;然而,似乎有错误,因为每个都试图从相同的来源读取(我认为)。解决这个问题的最好方法是什么?谢谢!! 以下是错误: 谢谢!!
如何监控LMAX Disruptor?假设我有3个环缓冲区,并希望提供一个用户界面来提供环缓冲区的信息。
我试图做的是防止用户在我的输入中输入空字符串。现在,用户只能输入数字。然而,没有什么能阻止他们将文本字段留空。我想限制他们在程序空白时按我的按钮启动程序。 现在,我的文本字段最初是空白的,按钮最初是灰色的。但当我输入一些东西时,按钮保持灰色。请记住,所有这些代码都在构造函数中。
我想在JavaFX中使用拖放,并有一个功能,您可以直观地看到正在拖动的项目。我已经实现了我认为可行的解决方案,但API似乎存在问题。 根据API start DragAndDrop(TransferMode...)必须在setOnDragDetted中初始化。这是我使用Dragboard存储我想传输到另一个节点的内容的地方。 编辑:这似乎与TrasferMode有关。如果我使用TransferMo
概述 无干扰模式将只在显示器中以全屏模式显示你的文件,可以在菜单栏中的View - 切换无干扰模式进入无干扰模式,快捷键也可以。 定制化 无干扰模式将使某些设置生效,默认设置(位于Packages/Default/Distraction Free.sublime-settings)是: { "line_numbers": false, "gutter": false, "draw_ce