Hi Parrott,

The PHP version uses something called 'mod_rewrite' to do url => action mapping.

You'll notice that in shindig/php there is a file called .htaccess that contains:
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule (.*) index.php [L]
</IfModule>

In other, more human, words what this does is that ANY url where it isn't a reference to an existing file or directory, it points the request too /index.php

When you then look in index.php you'll notice it has a url => class mapping:

$servletMap = array(
Config::get('web_prefix') . '/gadgets/files' => 'FilesServlet', Config::get('web_prefix') . '/gadgets/js' => 'JsServlet', Config::get('web_prefix') . '/gadgets/proxy' => 'ProxyServlet', Config::get('web_prefix') . '/gadgets/makeRequest' => 'ProxyServlet', Config::get('web_prefix') . '/gadgets/ifr' => 'GadgetRenderingServlet', Config::get('web_prefix') . '/gadgets/metadata' => 'JsonRpcServlet', Config::get('web_prefix') . '/social/data' => 'GadgetDataServlet', Config::get('web_prefix') . '/social/rest' => 'RestServlet', Config::get('web_prefix') . '/public.crt' => 'CertServlet'
                );

So it matches, lets say /gadgets/ifr to the class 'GadgetRenderingServlet', which it then instances and depending on the http method calls doGet / doPost / etc. From there on the event specific logic takes place.

This type of construct is quite a common and a popular solution to get pretty url's in PHP applications, since it's unseemly to always have to do /gadgets/ifr.php, and needing an actual gadgets directory, and a ifr.php file .. for simple programs that works, but for larger applications where you need a good source layout, this doesn't scale well.

A lot of hosting parties already have support for mod_rewrite and .htaccess files enables, since a lot of popular software, like for instance wordpress use this for their 'pretty urls' (ie have /category/ title-of-blog-post instead of /blog.php?id=12) so in most cases you don't have to do anything to make this work. However if it doesn't what you need to do is:

Edit your virtual host configuration and add (to enable .htaccess files to define apache behavior) an AllowOverride All, like :

        <VirtualHost your_ip:your_port>
               ServerName your.host
               DocumentRoot /var/www/html/shindig/php
               ... other normal settings in vhosts...
                <Directory />
                        AllowOverride All
                </Directory>
        </VirtualHost>

Also make sure that the mod_rewrite module is loaded, on most unix systems you'd look for a line like:

        LoadModule rewrite_module modules/mod_rewrite.so

if it's

        #LoadModule rewrite_module modules/mod_rewrite.so

instead, remove the # infront of it.

After making those change(s), restart apache, and you should be good to go :)

        -- Chris

On Jul 7, 2008, at 5:18 PM, Parrott, Justin wrote:

Hello,



I have tried both the Java and the PHP versions of shindig.  I am able
to get the java version built and deployed to a tomcat server
successfully but I would rather use the PHP version to integrate a
little nicer into my current applications.  When I download the PHP
version from svn following the instructions on the main apache shindig
website it doesn't appear to be complete.  I have the virtual hosting
server set up and rewrite is loaded.. but it is looking for a "gadget"
directory that doesn't exist under the php directory. Also, if I am to use the gadget directory underneath the "src" directory.. that also does
not have the "ifr" file that the test URLs are referencing.  I'm
probably doing something wrong and it's more than likely pretty simple
but I'm not sure what it is after several attempts, so if anyone can
help clear up the instructions and steps to get this working it would be
greatly appreciated.  Thanks.











Confidentiality Notice: The information contained in this electronic transmission is confidential and may be legally privileged. It is intended only for the addressee(s) named above. If you are not an intended recipient, be aware that any disclosure, copying, distribution or use of the information contained in this transmission is prohibited and may be unlawful. If you have received this transmission in error, please notify us by telephone (513) 229-5500 or by email ([EMAIL PROTECTED]). After replying, please erase it from your computer system.




Reply via email to