Skip to content
Christian Knuth edited this page Nov 4, 2016 · 20 revisions

Where can I get more help?

Should I use the static calling convention (F3::xxx) or call an instance of F3 (like $f3->xxx)?

Static method calling convention has been deprecated. It will be dropped in the next major version.

Can I run F3 in a sub-directory?

Of course you can. In most cases, you may wish to run F3 on your own virtual host, so that it's always the root of your domain. When time comes to go into production, it's just a matter of uploading to the Web host's root folder.

On the other hand, if your F3-enabled app is not located in the Web root, i.e. on shared Web hosting services, where you may not have full control over virtual hosts setup, here are some pointers:-

  • Let's say F3 runs in mydomain.com/myapp/. If your .htaccess and index.php files are saved in that folder, you don't need to insert an Apache RewriteBase directive in your .htaccess. Apache is already aware that the current path is the RewriteBase by default.

  • F3 redirects all URLs ending with / (except the domain root) to the relative base, e.g. when your browser tries to access the page at mydomain.com/myapp/page1/, F3 will automatically reroute the request to mydomain.com/myapp/page1. All relative URLs in your templates start at mydomain.com/myapp/. As far as the framework is concerned, page1 is just a file in the mydomain.com/myapp/ directory. Using this as a guide, the full URL of <a href="page2"> is mydomain.com/myapp/page2. If this is not desired, your can use the ../ URL prefix as many times as you need to get to the right path. Remember, any URL referenced by your HTML templates/views will be relative to mydomain.com/myapp/.

    If you feel that your templates/views are becoming too verbose and you wish to override the current base URL, the alternative solution is to use the HTML base tag. Insert the tag somewhere in the <head> section of your template. Something like <base href="myapp/altpath/" /> instructs your browser to use mydomain.com/myapp/altpath/ as the prefix for all relative URLs. In our example above, the browser will now translate the relative URL page2 to mydomain.com/myapp/altpath/page2, instead of mydomain.com/myapp/page2.

    Unfortunately, Internet Explorer browser only supports absolute paths as base href value. Adding <base href="http://mydomain.com/myapp/"> may not be convenient in a handful of cases, as you might need to switch from dev (http) and live server (https) every now and then. So you need to dynamically calculate the absolute base path. To do so, insert <base href="{{@SCHEME.'://'.@HOST.@BASE.'/'}}"> to your F3 template. The base tag also affects CSS links you might have used in a relative way, like background-image: url(../img/page_bg.jpg). They should work as expected.