这是我的控制器:
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class RegisterController extends Controller
{
public function register(Request $request)
{
dd('aa');
}
}
Run Code Online (Sandbox Code Playgroud)
如屏幕截图所示,该类存在并且位于正确的位置:
我的api.php路线:
Route::get('register', 'Api\RegisterController@register');
Run Code Online (Sandbox Code Playgroud)
当我register使用 Postman 到达我的路线时,它给了我以下错误:
目标类 [Api\RegisterController] 不存在。
更新:
多亏了答案,我才能修复它。我决定为此路由使用完全限定的类名,但还有其他选项,如答案中所述。
Route::get('register', 'App\Http\Controllers\Api\RegisterController@register');
Run Code Online (Sandbox Code Playgroud) \n\n无需安装、更新或删除\n生成优化的自动加载文件\n位于 C:/wamp64/www/vuexylaravel/app\\Helpers\\helpers.php 的类 App\\Helpers\\Helper 不符合\npsr-4 自动加载标准。跳过。\n> Illuminate\\Foundation\\ComposerScripts::postAutoloadDump\n> @php artisan package:discover --ansi
\n
Error \n\n Undefined constant Illuminate\\Http\\Request::HEADER_X_FORWARDED_ALL\n at C:\\wamp64\\www\\vuexylaravel\\vendor\\fideloper\\proxy\\config\\trustedproxy.php:48\n 44\xe2\x96\x95 * - 'HEADER_X_FORWARDED_AWS_ELB' (If you are using AWS Elastic Load Balancer)\n 45\xe2\x96\x95 *\n 46\xe2\x96\x95 * @link https://symfony.com/doc/current/deployment/proxies.html\n 47\xe2\x96\x95 */\n \xe2\x9e\x9c 48\xe2\x96\x95 'headers' => Illuminate\\Http\\Request::HEADER_X_FORWARDED_ALL,\n 49\xe2\x96\x95\n 50\xe2\x96\x95 ];\n 51\xe2\x96\x95\n\n 1 C:\\wamp64\\www\\vuexylaravel\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\ServiceProvider.php:138\n require()\n\n 2 C:\\wamp64\\www\\vuexylaravel\\vendor\\fideloper\\proxy\\src\\TrustedProxyServiceProvider.php:28\n Illuminate\\Support\\ServiceProvider::mergeConfigFrom("C:\\wamp64\\www\\vuexylaravel\\vendor\\fideloper\\proxy\\config\\trustedproxy.php", "trustedproxy")\nScript @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1\nRun Code Online (Sandbox Code Playgroud)\n 今天早上,每当我在 Mac 中运行 Vagrant 时,我就会突然看到这个弹出窗口。
\n\nVirtualBox版本 7.0.4 r154605 (Qt5.15.2)。
\n macOS\xc2\xa0v12 (蒙特雷)、MacBook Pro(视网膜显示屏,15 英寸,2015 年中)
| Ubuntu 长期支持 | 定居者版本 | 家园版 | 分支 | 地位 |
|---|---|---|---|---|
| 20.04 | 11.x | 12.x | main | 开发/不稳定 |
| 20.04 | 11.x | 12.x | release | 稳定的 |
这里出了什么问题?
\n我安装了一个新的 Laravel 8 应用程序,然后我跑了……
npm install
Run Code Online (Sandbox Code Playgroud)
后来我跑...
npm run dev
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。
'mix' 不被识别为内部或外部命令
Run Code Online (Sandbox Code Playgroud)> @ dev E:\wamp64\www\Laravel8Projects\Laravel_Livewire_JetStream_Projects\jetstream_blog > npm run development > @ development E:\wamp64\www\Laravel8Projects\Laravel_Livewire_JetStream_Projects\jetstream_blog > mix 'mix' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ development: `mix` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @ development script. npm ERR! This is probably not a problem with npm. …
我正在使用laravel 8,现在我想安装Vue.js。我正在尝试这样
composer require laravel/uiphp artisan ui vuephp artisan ui vue --auth运行命令时出现标题错误:
php artisan db:seed
Run Code Online (Sandbox Code Playgroud)
我不知道这个问题从何而来。我正在寻找代码示例和解决方案,但我什么也没找到:(
文章TableSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
// use Laracasts\TestDummy\Factory as TestDummy;
class ArticlesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Article::class, 30)->create();
}
}
Run Code Online (Sandbox Code Playgroud)
文章工厂.php
<?php
namespace Database\Factories;
use App\Models\Model;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ModelFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = App\Models\Article::class;
/**
* Define the model's default …Run Code Online (Sandbox Code Playgroud) 我在 Windows 10 中遇到以下问题(在 Ubuntu 中工作正常):
我正在 Laravel 8 中使用 Sail 当我APP_PORT在.env...上创建变量时
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_PORT=3000
Run Code Online (Sandbox Code Playgroud)
...并启动网络,sail up我收到此错误:
services.laravel.test.ports contains an invalid type, it should be a number, or an object
Run Code Online (Sandbox Code Playgroud)
这就是docker-compose.yml看起来的样子
version: '3'
services:
laravel.test:
build:
context: ./docker/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
...
Run Code Online (Sandbox Code Playgroud)
我知道我可以直接输入ports: - '3000:80',但由于我在团队中工作并且该php artisan sail:install命令将覆盖该docker-compose.yml文件,因此我不想更改该docker-compose.yml文件。
提前致谢。
我可以在网上找到的所有信息都表明您应该通过运行composer require laravel/ui然后安装 bootstrap php artisan ui boostrap。然而,在 Laravel 8 中,laravel/ui已被弃用。有没有新的/更好的安装引导程序的方法?
我在尝试最近发布的 laravel 8 时遇到了一个问题,我试图找出有哪些变化以及它是如何工作的。当我这样做时,我遇到了分页 Laravel 8 UI 变得混乱的问题,并且不知何故发生了。有没有人可以帮助我?或者经历过同样的事情?
像这样我在 Laravel 8 Laravel 8 paginate UI 中得到的视图
这是我使用的代码“Index.blade.php”
@extends('layouts.app')
@section('title', 'Post')
@section('contents')
<div class="container">
<div class="row">
@foreach ($posts as $post)
<div class="col-md-4 mb-4">
<div class="row">
<div class="card mb-4">
<div class="card-header">
{{ $post->title }}
</div>
<div class="card-body">
{{ $post->body }}
</div>
<div class="card-footer">
{{ $post->created_at->diffForHumans() }}
</div>
</div>
</div>
</div>
@endforeach
</div>
<div class="d-felx justify-content-center">
{{ $posts->links() }}
</div>
</div>
@endsection
Run Code Online (Sandbox Code Playgroud)
我用于 PostController 的代码
<?php
namespace App\Http\Controllers;
use App\Models\Posts;
use Illuminate\Http\Request; …Run Code Online (Sandbox Code Playgroud) 我正在关注这个教程,
我在Windows系统上安装了Docker和WSL2(Ubuntu 20.04.4 LTS),如下图所示,

当我尝试使用命令运行 Laravel 项目时,
./vendor/bin/sail up
Run Code Online (Sandbox Code Playgroud)
为什么我收到错误没有找到这样的文件或目录?
laravel-8 ×10
laravel ×7
php ×4
docker ×2
css ×1
homebrew ×1
homestead ×1
laravel-9 ×1
laravel-mix ×1
laravel-sail ×1
npm ×1
pagination ×1
vue.js ×1