'Invalid path alias: @web/themes/spacelab'

Yii2 advanced template.

I had this error:

exception ‘yii\base\InvalidParamException’ with message ‘Invalid path alias: @web/themes/spacelab’ in /var/www/yiiadvanced/_protected/vendor/yiisoft/yii2/BaseYii.php:152

It appeared when I turned back from production environment to development environment.

Initially all worked fine.

This happens in frontend, backend works fine.

I’m not very familar with the advanced template but lets try to figure out what is going wrong:

  • When you now switch back to production?

  • Does it work again?

  • In whitch local path do you store your template?

I’m asking because as far as I know you have multiple web folders.

app/frontend/web

app/backend/web

Regarding the documentation @web is pointing to the web folder of the currently running application. (and frontend / backend are seperate applications)

Means (when I understand it correct):

If you have the theme only under /app/backend/web you will have "invalid path" in frontend.

Regards

I have production in host server and development in local server.

Frontend and backend are seperated in _protected folder.

Themes are in public folder.

This works in backend …config/main.php:

‘components’ => [

    'view' => [


        'theme' => [


            'pathMap' => ['@app/views' => '@webroot/themes/spacelab/views'],


            'baseUrl' => '@web/themes/spacelab',


        ],.....

It is same in frontend, but does’t work.

OK. I solved this, not very stylish way.

In local server I switched to production and changed my local setting by hand, not by php init.