yii2 中出现未知类异常的 404 错误

404 error with unknownclass exception in yii2

我是yii2的新手。我已成功提取高级 yii2 zip 模板。 已经设置了 db 和 .htaccess 文件。

关于在控制器中创建新控制器、模型和操作并导航到该位置。例如:http://localhost/advanced/frontend/web/mysetofusers/signin

我面临三个问题。 1. 提示404错误。 2. 说 UnKnownClassException - 即无法在文件 frontendControllers\mysetofusersController.php namespace 中找到 mysetofusersController 丢失?即使文件在文件夹中并且使用了确切的名称 space。 3. 它总是重定向到 site/index 页面而不是显示 mysetofusers/signin。这次在Yii调试器中也不例外。

a=另请注意,我尝试使用 gii 和模型的扩展 class 创建模型。

似乎没有任何效果。 请帮帮我。我被卡住了,无法继续工作。

谢谢:)

404 Yii 2.0 中的错误通常来自错误的 urlManager 配置或 Server 配置。

在创建 api 模块之前,请确保您的 REST 应用程序在遵循 the official docs 之后可以正常工作。如果不是,则可能是服务器配置问题。

为了让 REST 工作,漂亮的 urls 必须通过配置 .htaccess 文件启用(如果使用 apache 服务器 ) 像这样:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

那你就可以去restructuring your app了。

这是一个尚未完成的 working repo where you'll find the configs I used for the api folder and the onces 我用于 web 文件夹 + 这两个文件夹中的两个 .htaccess 文件。

希望对您有所帮助。