So I am trying to use the Admin Lte Package with Yii2 Basic. I have followed a few tutorials online on how to install it. It looks awesome after installation but I have a problem. My Issue is that, I want this new View to work only when the user is authenticated else, it should follow the default Yii2 Application. How do I condition this in the web.php or if there's another way out, I will like to know.
Config/web.php
'view' => [
'theme' => [
'pathMap' => [
'@app/views' => '@vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app'
],
],
],
As an idea, you may create 2 entry points:
@app/web/index.php(let's call itmain)@app/web/adminlte.php(let's call itadminlte)index.phpwill include its own config file (in which there is no adminlte-implementation).adminlte.phpwill connect its config file (in which has adminlte-implementation). Both entry points will triggerApplication::run()to run Yii-applications.Configure URL splitting on the web server side. For example:
example.com-->index.phpcp.example.com-->adminlte.phpor
example.com/cp/-->adminlte.phpexample.com-->index.phpor in some other way that you like.Plus, add redirects from one Application to another: If the user opene URL based
adminlteand he is not authorized, redirect him tomain. If the user opene URL basedmainand he is authorized, redirect him toadminlte.As a result, you get 2 entry points (2 separate Yii applications). But at the same time, they will be able to work without problems with the same database, and the same codebase (models, auth, etc).