How do I make my Kohana website portable?

I just finished coding the Kohana PHP online portal .

It works fine on my PC, but when I tried to host it on another server, "BONK!", It shows up without displaying product images.

I don't even know what's going on.

What rules should I follow to make my Kohana apps portable?

0


a source to share


3 answers


I use Kohana to develop multiple websites, and here are some tricks I use to make sure websites are portable, since I can just upload files from my IDE to the server and run them without having to change anything:

  • Use the same directory structure. For example, in my case, I put the main Kohana folders in <drive><somepath>/apps/kohana/system/

    both <drive><somepath>/apps/kohana/modules/

    the local drive /apps/kohana/system/

    and /apps/kohana/modules/

    the server. Likewise, I have set the local XMPP htdocs <drive><somepath>/public_html/

    to follow the server setup /public_html

    . This way I don't need to modify index.php

    when I upload it to the server. Use relative paths .

  • As kfederov suggested, use url::base()

    src = ".." in all your templates. The way I do it is by assigning $this->template->baseurl = url::base();

    in my Controller_Template (I am using Kohana 3, but the method is almost the same for Kohana 2.x) and use {$baseurl}

    in Smarty templates (I highly recommend using the Smarty system template - you can find the module on the Kohana forum).

  • Use the same database name, username and password in both development environment and server, so I don't need to change config/database.php

    , obviously.

  • If you host multiple sites with different domains on the same hosting, it is obvious that you cannot use /public_html

    as the document root for all but one of the sites. You will most likely have to configure those non-primary domains to point to different folders, for example in my case I put them in folders /hosted/*/

    and set up my cPanel server accordingly. To duplicate this parameter in your local environment, you need to use localhost subdomains, for which you also need to change httpd.conf

    your HOSTS file, as shown below:

    • Add virtual host to httpd.conf

      . eg:

      <VirtualHost *:80>
        DocumentRoot /path/to/hosted/coolwebsite
        ServerName coolwebsite.localhost
      </VirtualHost>
      
            

    • Add to your HOSTS file ( C:\WINDOWS\system32\drivers\etc\hosts

      if on Windows):

      127.0.0.1     coolwebsite.localhost
      
            

    • You are now using http://coolwebsite.localhost/

      to access the website on the local web server for your development environment.



Hope this helps!

+3


a source


Make sure to update your .htaccess, values ​​in your index.php and possibly your config files.



0


a source


  • Check the files .htaccess

    and bootstrap.php

    for the correct path to the site.

  • Make sure you used URL::base()

    c src="..."

    .

0


a source







All Articles