Bootstrap file for Zend Amf
There seems to be lots of questions about the best way to setup your bootstrap/endpoint/index.php file in order to work with Zend Amf. The idea of leveraging the Zend MVC framework to route to your server endpoint is a common question but personally seems like a bad idea. Although it may seem convenient it does not provide any MVC integration and second will slow down the response time of your service greatly.
I typically have something like the following structure:
public/
.htaccess
index.php
xmlrpc.php
jsonrpc.php
amf.php
In my .htaccess, I have the following:
php_value date.timezone "UTC"
php_value short_open_tag 1
php_value error_reporting 8191
php_flag display_errors Off
php_flag display_startup_errors Off
# Rewrite Rules
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^/?xmlrpc xmlrpc.php [NC,L]
RewriteRule ^/?jsonrpc jsonrpc.php [NC,L]
RewriteRule ^/?amf amf.php [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Then, in my amf.php, I’d have the following:
setClass(...); // etc...
echo $server->handle();
The rewrite rules allow you to go directly to the given file, and then each file sets up the include_path, autoloading, and the server.


Recent Comments