Last active
February 8, 2019 08:45
-
-
Save erycamel/9d604102e43f6954547e05b33b9f27a1 to your computer and use it in GitHub Desktop.
Yii2 Framework - Multi FrontEnd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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',
'Production' => [
'path' => 'prod',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'frontend/runtime',
'frontend/web/assets',
];
https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/topic-adding-more-apps.md