Võ Minh Tâm
Võ Minh Tâm

Reputation: 59

how to change name folder frontend and backend in yii2?

Currently my url is http://localhost/halodocnew/frontend/web/index.php?r=site%2Flogin I want to change name folder frontend to client for all action.

Please help me

Thank all so much

Upvotes: 1

Views: 3392

Answers (2)

yogesh godse
yogesh godse

Reputation: 110

Suppose you want to rename backend to admin the follow the following steps

1)Rename backend folder to admin

2)Update Bootstrap.php under common/config/Bootstrap.php

Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend'); 

To

Yii::setAlias('@admin', dirname(dirname(__DIR__)) . '/admin');

3)Update site controller namespace under admin/controller/siteController.php backend\controllers; to namespace admin\controllers;

4) Update main.php ubder admin/config 'controllerNamespace' => 'backend\controllers' to 'controllerNamespace' => 'admin\controllers'

Upvotes: 2

Muhammad Shahzad
Muhammad Shahzad

Reputation: 9652

For Quick solution:

Copy and Paste your frontend folder in same directory and rename it to client

Open halodocnew\common\config\bootstrap.php

Add alias: Yii::setAlias('client', dirname(dirname(__DIR__)) . '/client');

Access in browser: http://localhost/halodocnew/client/web/index.php

Another Solution:

  • Go into halodocnew\environments\dev\
  • Copy & Paste frontend in this folder and rename it to client.
  • Then go to halodocnew\environments\prod\
  • Copy & Paste frontend in this folder and rename it to client.
  • Open halodocnew\environments\index.php
  • Find 'Development' => [ 'path' => 'dev', 'setWritable' => [ 'backend/runtime', 'backend/web/assets',
  • Add 'Development' => [ 'path' => 'dev', 'setWritable' => [ 'backend/runtime', 'backend/web/assets', 'client/runtime', 'client/web/assets',
  • Do same above for 'Production' => [ 'path' => 'prod',

  • Go into your project root directory and run php init

  • Copy web and veiws folder from frontend to client
  • Open halodocnew\common\config\bootstrap.php
  • Add alias: Yii::setAlias('client', dirname(dirname(__DIR__)) . '/client');
  • Open browser and access your desired directory http://localhost/halodocnew/client/web/index.php

I don't think it is sooper dooper solution but I used these methods =:)

Upvotes: 1

Related Questions