Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm using Kohana to develop a few websites and here are some tricks that I use to make sure that the websites are portable, as in I can just upload the files from my development environment into the server and have them running without having to modify anything:</p> <ol> <li><p>Use the same directory structure. For example in my case I put the Kohana core folders into <code>&lt;drive&gt;&lt;somepath&gt;/apps/kohana/system/</code> and <code>&lt;drive&gt;&lt;somepath&gt;/apps/kohana/modules/</code> on my local disk and <code>/apps/kohana/system/</code> and <code>/apps/kohana/modules/</code> on the server. Similarly, I set my local XAMPP htdocs to <code>&lt;drive&gt;&lt;somepath&gt;/public_html/</code> to follow the server setting of <code>/public_html</code>. That way I don't have to modify <code>index.php</code> when I upload it to the server. <strong>Use relative paths</strong>.</p></li> <li><p>Like kfederov suggested, use <code>url::base()</code> in all your src=".." in your templates. The way I do it is by assigning <code>$this-&gt;template-&gt;baseurl = url::base();</code> in my Controller_Template (I'm using Kohana 3 but the method is almost the same for Kohana 2.x) and use <code>{$baseurl}</code> in the Smarty templates (I highly recommend using Smarty template system -- you can find the module in the Kohana forum).</p></li> <li><p>Use the same database name, username and password in both development and server environment so that I don't have to modify <code>config/database.php</code>, obviously.</p></li> <li><p>If you are hosting multiple websites with different domains on the same hosting, obviously you cannot use <code>/public_html</code> as the document root for all but one of the websites. You most probably have to configure those non-primary domains to point to different folders, for example in my case I put them in <code>/hosted/*/</code> folders and configure my server cPanel accordingly. To duplicate this setting in your local environment, you need to use localhost subdomains, which requires you to modify <code>httpd.conf</code> and your HOSTS file accordingly, as below:</p> <ol> <li><p>Add Virtual Host in <code>httpd.conf</code>. e.g:</p> <blockquote> <pre><code>&lt;VirtualHost *:80&gt; DocumentRoot /path/to/hosted/coolwebsite ServerName coolwebsite.localhost &lt;/VirtualHost&gt; </code></pre> </blockquote></li> <li><p>Add to your HOSTS file (<code>C:\WINDOWS\system32\drivers\etc\hosts</code> if under Windows):</p> <blockquote> <pre><code>127.0.0.1 coolwebsite.localhost </code></pre> </blockquote></li> <li><p>Now you use <code>http://coolwebsite.localhost/</code> to access the website on locally running web server for your development environment.</p></li> </ol></li> </ol> <p>Hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload