Changing an advanced application template
By default, Yii2's Advanced template has console
, frontend
, and backend
applications. However, in your specific case, you can rename the existing ones and create your own applications. For example you can add the api
application if you develop an API for your site.
Getting ready
Create a new yii2-app-advanced
project by using the Composer package manager, as described in the official guide at https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md.
How to do it...
- Copy the
backend
directory content to a newapi
directory in the root of your application. - Open the
api/config/main.php
file and change thecontrollerNamespace
option value:return [ 'id' => 'app-manager', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'api\controllers', // .... ]
- Open
api/assets/AppAsset.php
andapi/controllers/SiteController.php
and change the namespaces...