Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced template issue #1742

Closed
asofter opened this issue Jan 2, 2014 · 14 comments
Closed

Advanced template issue #1742

asofter opened this issue Jan 2, 2014 · 14 comments

Comments

@asofter
Copy link

asofter commented Jan 2, 2014

Hello,
I am using your advanced template for application and I have frontend and backend part.
I set url like backend.site.com, frontend.site.com and I need thing when user opens
frontend.site.com/admin he will see backend.site.com

I create directory admin in frontend/web and add .htaccess with DirectoryIndex index.php
and index.php like this

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

define('FRONTEND_DIR', __DIR__ . "/../../../frontend/web/");

require(__DIR__ . '/../../../vendor/autoload.php');
require(__DIR__ . '/../../../vendor/yiisoft/yii2/yii/Yii.php');

$config = yii\helpers\ArrayHelper::merge(
    require(FRONTEND_DIR. '/../config/main.php'),
    require(FRONTEND_DIR . '/../config/main-local.php')
);
$config['basePath'] = FRONTEND_URL;

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

but I can't see what I need. I've made many changes to this script with directory and all but in all cases I see

Invalid Configuration – yii\base\InvalidConfigException

The directory does not exist
@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

$config['basePath'] = FRONTEND_DIR_; ?

@asofter
Copy link
Author

asofter commented Jan 2, 2014

define('FRONTEND_DIR', DIR . "/../../../frontend/web/");

it's like path to frontend directory

@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

You are using FRONTEND_URL, not FRONTEND_DIR.

@asofter
Copy link
Author

asofter commented Jan 2, 2014

oh, it was my fault writing this issue, in real script it's correct.

@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

What is the complete error call stack?

@asofter
Copy link
Author

asofter commented Jan 2, 2014

FRONTEND_DIR looks like /home/primegate/data/www/dev.primegate.ru/frontend/

2014/01/02 23:54:04 [109.229.1.1] [error] [yii\base\InvalidConfigException] exception 'yii\base\InvalidConfigException' with message 'The directory does not exist: /home/primegate/data/www/dev.primegate.ru/app/web/admin/assets' in /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/web/AssetManager.php:107
Stack trace:
#0 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/Object.php(49): yii\web\AssetManager->init()
#1 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/BaseYii.php(383): yii\base\Object->__construct()
#2 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/Module.php(465): yii\BaseYii::createObject(Array)
#3 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/web/Application.php(160): yii\base\Module->getComponent('assetManager')
#4 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/web/View.php(137): yii\web\Application->getAssetManager()
#5 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/web/View.php(236): yii\web\View->getAssetManager()
#6 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/web/AssetBundle.php(121): yii\web\View->registerAssetBundle('frontend\assets...')
#7 /home/primegate/data/www/dev.primegate.ru/frontend/modules/site/views/layouts/landing.php(13): yii\web\AssetBundle::register(Object(yii\web\View))
#8 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/View.php(292): require('/home/primegate...')
#9 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/View.php(232): yii\base\View->renderPhpFile('/home/primegate...', Array)
#10 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/Controller.php(310): yii\base\View->renderFile('/home/primegate...', Array, Object(frontend\modules\site\controllers\DefaultController))
#11 /home/primegate/data/www/dev.primegate.ru/frontend/modules/site/controllers/DefaultController.php(16): yii\base\Controller->render('landing')
#12 [internal function]: frontend\modules\site\controllers\DefaultController->actionIndex()
#13 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/InlineAction.php(53): call_user_func_array(Array, Array)
#14 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/Controller.php(130): yii\base\InlineAction->runWithParams(Array)
#15 /home/primegate/data/www/dev.primegate.ru/common/controllers/FrontendController.php(33): yii\base\Controller->runAction('index', Array)
#16 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/Module.php(586): common\controllers\FrontendController->runAction('index', Array)
#17 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/web/Application.php(77): yii\base\Module->runAction('site/default/in...', Array)
#18 /home/primegate/data/www/dev.primegate.ru/vendor/yiisoft/yii2/yii/base/Application.php(289): yii\web\Application->handleRequest(Object(yii\web\Request))
#19 /home/primegate/data/www/dev.primegate.ru/app/web/admin/index.php(16): yii\base\Application->run()
#20 {main}

@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

The error message already says it clearly: The directory does not exist: /home/primegate/data/www/dev.primegate.ru/app/web/admin/assets

@asofter
Copy link
Author

asofter commented Jan 2, 2014

but I set the right basePath, why it takes another?

@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

basePath specifies the application base path (the root directory that contains your private source files).
The directory missing here is about the base path for keeping published asset files. This directory by default is located under the public Web folder and is determined by the entry script file location. It has nothing to do with the application base path.

@asofter
Copy link
Author

asofter commented Jan 2, 2014

how I can edit @app path?

@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

@app is the alias for the application base path. You already specified it.
The one you have problem with is AssetManager::basePath. You may manually configure it in your app config.

@asofter
Copy link
Author

asofter commented Jan 2, 2014

How I can set it manually with app config?

@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

[
    'components' => [
         'assetManager' => [
              'basePath' => '...',
        ]
    ],
]

@qiangxue qiangxue closed this as completed Jan 2, 2014
@qiangxue
Copy link
Member

qiangxue commented Jan 2, 2014

What's the remaining problem?

I am using your advanced template for application and I have frontend and backend part.
I set url like backend.site.com, frontend.site.com and I need thing when user opens
frontend.site.com/admin he will see backend.site.com

You don't need to change your code. You just need to create an Apache alias "admin" which points to your backend. Please refer to Apache docs on how to achieve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants