Yii Framework Forum: Yii Advanced Application Frontend & Backend Urls - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Advanced Application Frontend & Backend Urls

#1 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 26 August 2013 - 12:47 PM

Hi,

I've been following Yii2 since quite some time and after Public Preview thought to give it a try. In particular I liked the advanced application structure and thought to move ahead with it.

However, while installing, realized that accessing frontend & backend is done via
http://example.com/frontend/web/ and http://example.com/backend/web/

Would it be possible to have them as
http://example.com/ (pointing to frontend) and http://example.com/backend/
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,694
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 26 August 2013 - 01:26 PM

It's quite easily to do this by moving the contents of frontend/web to webroot and backend/web to webroot/backend.
You'll also need to modify require() dirs inside index.php

Yet another way is to place all dirs under webroot and edit .htaccess so that webroot will be rewrited to subdir. Kinda tricky though.
God is real unless declared as integer
0

#3 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 27 August 2013 - 12:03 AM

Won't moving frontend/web under webroot and backend/web under webroot/backend merge too application code?

It will mean I'm placing backend directory under frontend/web. right?


.htaccess based solution could be tricky to manage for sure.


Is it that the directory structure is decided to have two separate domain / sub-domains pointing to both the applications?
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,428
  • Joined: 17-January 09
  • Location:Russia

Posted 27 August 2013 - 03:03 AM

Yes, the idea is to have a subdomain for backend.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 27 August 2013 - 10:10 AM

@samdark, Thank you. The query is resolved now.

Please close the thread.
0

#6 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 603
  • Joined: 29-August 12

Posted 24 April 2014 - 05:55 AM

View Postmastermunj, on 26 August 2013 - 12:47 PM, said:

However, while installing, realized that accessing frontend & backend is done via
http://example.com/frontend/web/ and http://example.com/backend/web/

Would it be possible to have them as
http://example.com/ (pointing to frontend) and http://example.com/backend/

Released a new application template yii2-app-practical to the community that does this automatically.
0

#7 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,428
  • Joined: 17-January 09
  • Location:Russia

Posted 24 April 2014 - 06:20 AM

It's not recommended to have source code under webroot. You need to add a warning about securing it via webserver config.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#8 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 603
  • Joined: 29-August 12

Posted 24 April 2014 - 06:24 AM

View Postsamdark, on 24 April 2014 - 06:20 AM, said:

It's not recommended to have source code under webroot. You need to add a warning about securing it via webserver config.

Not sure I understood. Which source code (can you elaborate)?

Only the index.php will move to webroot (along with the runtime assets folder from the frontend/web). All other structure remain exactly the same as the yii2-advanced app (the same security should hold good IMO). Its only config file locations change.
0

#9 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 603
  • Joined: 29-August 12

Posted 24 April 2014 - 06:42 AM

If you look at the yii2-app-practical directory structure - its exactly same as yii2-app-advanced except that it does the following:

  • moves frontend/web/index.php, favicon, and robots.txt to root.
  • moves frontend/web/assets to root.
  • deletes frontend/web folder
  • carefully changes index.php configuration locations to point to the new relative vendor, common, and frontend paths.

And voila... you can now access frontend from the approot. B)
0

#10 User is offline   Gizmo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 22-January 12

Posted 24 April 2014 - 02:53 PM

Why not using URL rewrite similar to ZF2 where module application is default even if you don't mention it in the URL. I'm just asking i don't have any idea how it's handled in YII2 because i didn't have enough time to analyze it.
0

#11 User is offline   LeVanLau 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 24-April 14

Posted 24 April 2014 - 10:16 PM

Hello there,
You can view this link that it's very useful:
aaronfrancis.com/blog/2014/1/9/hosting-an-advanced-yii2-application-on-heroku
Good luck.
0

#12 User is offline   whatisnew 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 27-April 14

Posted 27 April 2014 - 06:16 AM

which file is config to those url links?

http://www.yiiframew...s-advanced.html
Creating links from backend to frontend
return [
'components' => [
'urlManager' => [
// here is your normal backend url manager config
],
'urlManagerFrontend' => [
// here is your frontend URL manager config
],

],
];
0

#13 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,428
  • Joined: 17-January 09
  • Location:Russia

Posted 27 April 2014 - 02:43 PM

backend/config/main.php
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#14 User is offline   marciocamello 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 05-January 14

Posted 08 May 2014 - 02:11 PM

View Postsamdark, on 27 April 2014 - 02:43 PM, said:

backend/config/main.php


How to use across subdomains? with advanced application, I tried this way

/common/main-local.php


'session' => [
'savePath' => '\mypath\common\session',
'cookieParams' => [
'path' => '/',
'domain' => '.mydomain.com',
]
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_mydomain',
'domain' => '.mydomain.com',
'path' => '/',
]
],

This example for
mydomain.com
submain1.mydomain.com
subdomain2.mydomain.com
etc

All applications, need get user sessions/cookies, etc.

Any idea?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users