shared entry point. is it ok solution?

hello

i’m trying to achieve single entry point for front and back, shared assets and single config. when link starts with ‘admin’ i want to proceed controllers used for backend, otherwise default to frontend. i did the below, it works, but is it ok? maybe there’s better way. i kinda don’t like the idea of module but i don’t know what drawbacks give module… probably module is the way to go?

/public/admin/… => triggers backend


@mybase

├───backend

│   ├───controllers

│   ├───models

│   └───views

├───common

│   │   config.php

│   ├───components

│   │       mybootstrap.php

│   │       AdminRule.php

│   └───models

├───frontend

│   ├───controllers

│   ├───models

│   └───views

├───public

│   │   index.php

│   └───assets

└───tests

rule used in config


<?php //AdminRule.php

namespace common\components;


use yii\web\UrlRule;


class AdminRule extends UrlRule

{

	public $pattern = '<is_admin:(admin)>/<controller>/<action>';

	public $route = '<controller>/<action>';

	public $defaults = ['controller' =>'site', 'action'=>'index'];

		

	/**

	 * (non-PHPdoc)

	 * @see \yii\web\UrlRuleInterface::parseRequest()

	 */

	public function parseRequest($manager, $request)

	{

		$parsed = parent::parseRequest($manager, $request);

		

		if (is_array($parsed) && !empty(@$parsed[1]['is_admin'])) {//point to backend

			unset($parsed[1]['is_admin']);

			\Yii::$app->controllerNamespace = '\backend\controllers';

			\Yii::$app->basePath = \Yii::getAlias('@mybase/backend');

		}

		

		return $parsed;

	}


	/**

	 * (non-PHPdoc)

	 * @see \yii\web\UrlRuleInterface::createUrl()

	 */

	public function createUrl($manager, $route, $params)

	{

		return parent::createUrl($manager, $route, $params);

	}

}

went for module. topic can be closed