Yii2: Recommendate frontend & backend configuration

Skenario frontend dan backend, yang direkomendasikan (oleh saya).

#) Misal web root lokal ada c:\xampp\htdocs\
#) Misal kita instal advanced aplication template
frontend/web
backend/web
– Letakkan diluar web root
misal c:\xampp\yii-application
– jadi
c:\xampp\yii-application\backend
c:\xampp\yii-application\frontend
#) Kita ingin kek gini
http://localhost untuk frontend/web
http://localhost/administrator untuk backend/web
#) Copy isi folder frontend/web lalu paste di web root c:\xampp\htdocs\
sesuaikan file index.php

<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/../../yii-application/vendor/autoload.php');
require(__DIR__ . '/../../yii-application/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../yii-application/common/config/bootstrap.php');
require(__DIR__ . '/../../yii-application/frontend/config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/../../yii-application/common/config/main.php'),
    require(__DIR__ . '/../../yii-application/common/config/main-local.php'),
    require(__DIR__ . '/../../yii-application/frontend/config/main.php'),
    require(__DIR__ . '/../../yii-application/frontend/config/main-local.php')
);

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

#) Copy isi folder backend/web lalu paste di web root c:\xampp\htdocs\administrator\
sesuaikan file index.php

#) Selesai..

Cara ini berlaku juga untuk share maupun private hosting

Leave a Reply

Your email address will not be published. Required fields are marked *