Skip to content

Instantly share code, notes, and snippets.

@erycamel
Last active February 8, 2019 08:45
Show Gist options
  • Save erycamel/9d604102e43f6954547e05b33b9f27a1 to your computer and use it in GitHub Desktop.
Save erycamel/9d604102e43f6954547e05b33b9f27a1 to your computer and use it in GitHub Desktop.
Yii2 Framework - Multi FrontEnd
1. Go into profas\environments\dev\
2. Copy & Paste frontend in this folder and rename it to client.
3. Then go to profas\environments\prod\
4. Copy & Paste frontend in this folder and rename it to client.
5. Open profas\environments\index.php
Find 'Development' => [
'path' => 'dev',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
Add 'Development' => [
'path' => 'dev',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'client/runtime',
'client/web/assets',
Do same above for 'Production' => [
'path' => 'prod',
6. Go into your project root directory and run php init
7. Copy web and veiws folder from frontend to client
8. Open profas\common\config\bootstrap.php
9. Add alias: Yii::setAlias('client', dirname(dirname(__DIR__)) . '/client');
10. Open browser and access your desired directory http://localhost/profas/client/web/index.php
@erycamel
Copy link
Author

Yii 2.0: How to hide /frontend/web in url addresses on apache

http://www.yiiframework.com/wiki/755/how-to-hide-frontend-web-in-url-addresses-on-apache/

@erycamel
Copy link
Author

erycamel commented Apr 21, 2017

Adding more applications

While having separate frontend and backend is common, sometimes it's not enough. For example, you may need additional application for, say, a blog. In order to get it:

Copy frontend to blog, environments/dev/frontend to environments/dev/blog and environments/prod/frontend to environments/prod/blog.
Adjust namespaces and paths to start with blog instead of frontend.
In common\config\bootstrap.php add Yii::setAlias('blog', dirname(dirname(DIR)) . '/blog');.
Make adjustments to environments/index.php (marked with +):
return [
'Development' => [
'path' => 'dev',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'frontend/runtime',
'frontend/web/assets',

  •       'blog/runtime',
    
  •       'blog/web/assets',
      ],
      'setExecutable' => [
          'yii',
          'yii_test',
      ],
      'setCookieValidationKey' => [
          'backend/config/main-local.php',
          'frontend/config/main-local.php',
    
  •       'blog/config/main-local.php',
      ],
    
    ],
    'Production' => [
    'path' => 'prod',
    'setWritable' => [
    'backend/runtime',
    'backend/web/assets',
    'frontend/runtime',
    'frontend/web/assets',
  •       'blog/runtime',
    
  •       'blog/web/assets',
      ],
      'setExecutable' => [
          'yii',
      ],
      'setCookieValidationKey' => [
          'backend/config/main-local.php',
          'frontend/config/main-local.php',
    
  •       'blog/config/main-local.php',
      ],
    
    ],
    ];

https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/topic-adding-more-apps.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment