RESTful Web Services: Not Found (#404)

Is it a misunderstanding on my part that we can run a quick sample of the REST API by following the quick guide here?

(btw you should also whitelist on the forum rule "no links on first post")

I followed it but it throws me 404:

It also did not mention the disappearance of .htaccess. While the frontend and backend works alright since they have index.php on the URL, but those proceeding to the API will be at a loss, why it’s always “object not found”. So I resolved this by adding .htaccess so it now directs me to the Yii app, but the Yii app still throws the 404.

Here is my current setup:



'id' => 'app-api',

'basePath' => dirname(__DIR__),


'user' => [

	'identityClass' => 'common\models\User',

	'enableAutoLogin' => false,


'request' => [

	'parsers' => [

		'application/json' => 'yii\web\JsonParser',



'urlManager' => [

	'enablePrettyUrl' => true,

	'enableStrictParsing' => true,

	'showScriptName' => false,

	'rules' => [


			'class' => 'yii\rest\UrlRule',

			'controller' => 'user',




Note that I have also tried to set enableStrictParsing to false for the urlManager but still the same

'enableStrictParsing' => false,



RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php


defined('YII_DEBUG') or define('YII_DEBUG', true);

defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/../../vendor/autoload.php');

require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');

$config = yii\helpers\ArrayHelper::merge(

    require(__DIR__ . '/../../common/config/main.php'),

    require(__DIR__ . '/../../common/config/main-local.php'),

    require(__DIR__ . '/../config/main.php'),

    require(__DIR__ . '/../config/main-local.php')


$application = new yii\web\Application($config);




namespace app\controllers;

use yii\rest\ActiveController;

use common\models\User;

class UserController extends ActiveController


    public $modelClass = 'common\models\User';




(truncated, this is the one generated together with the Advanced Application Template)

namespace common\models;

use Yii;

use yii\base\NotSupportedException;

use yii\behaviors\TimestampBehavior;

use yii\db\ActiveRecord;

use yii\web\IdentityInterface;

class User extends ActiveRecord implements IdentityInterface


    const STATUS_DELETED = 0;

    const STATUS_ACTIVE = 10;


     * @inheritdoc


    public static function tableName()


        return '{{%user}}';



[size="5"]Edit 1[/size]

I forgot to mention I was using the Advanced Template and haven’t done anything on the frontend and backend yet. I went directly to checkout the REST API. The quick start guide also did not mention where to put files for the API. Had to do a stackoverflow search

[size="5"]Edit 2[/size]

Solved the 404 problem now, but now this error

Class 'common\models\User' not found

I updated my codes above to reflect the latest and maybe someone can see where I did a wrong namespace usage.

[size="5"]Edit 3[/size]

Figured it all out. Had to re-init the dev mode to overwrite configs.