tags:

views:

617

answers:

4

I just finished coding an online portal with Kohana PHP.

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

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

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

A: 

Did you upload the product images to the webserver?

Gavin Miller
yes. the files are in the database table, in a column with BLOB type.
Attilah
+1  A: 

Be sure to update your .htaccess, values in your index.php and, perhaps, in your configuration files.

Mike Hordecki
Update them how?
notJim
Certain configuration fields may need the absolute path of the website AFAIR.
Mike Hordecki
A: 

1) check .htaccess, bootsrap.php for right site path

2) make sure you used url::base in src="..."

kfedorov
Could you give an example of number 2?
Svish
A: 

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:

  1. Use the same directory structure. For example in my case I put the Kohana core folders into <drive><somepath>/apps/kohana/system/ and <drive><somepath>/apps/kohana/modules/ on my local disk and /apps/kohana/system/ and /apps/kohana/modules/ on the server. Similarly, I set my local XAMPP htdocs to <drive><somepath>/public_html/ to follow the server setting of /public_html. That way I don't have to modify index.php when I upload it to the server. Use relative paths.

  2. Like kfederov suggested, use url::base() in all your src=".." in your templates. The way I do it is by assigning $this->template->baseurl = url::base(); in my Controller_Template (I'm using Kohana 3 but the method is almost the same for Kohana 2.x) and use {$baseurl} in the Smarty templates (I highly recommend using Smarty template system -- you can find the module in the Kohana forum).

  3. Use the same database name, username and password in both development and server environment so that I don't have to modify config/database.php, obviously.

  4. If you are hosting multiple websites with different domains on the same hosting, obviously you cannot use /public_html 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 /hosted/*/ 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 httpd.conf and your HOSTS file accordingly, as below:

    1. Add Virtual Host in httpd.conf. e.g:

      <VirtualHost *:80>
        DocumentRoot /path/to/hosted/coolwebsite
        ServerName coolwebsite.localhost
      </VirtualHost>
      
    2. Add to your HOSTS file (C:\WINDOWS\system32\drivers\etc\hosts if under Windows):

      127.0.0.1     coolwebsite.localhost
      
    3. Now you use http://coolwebsite.localhost/ to access the website on locally running web server for your development environment.

Hope this helps!

Lukman