ZF-6129: Multiple Services exposed on the same endpoint throws error on invocation if one of the services is invalid

Description

We are facing an issue with the gateway.php that we use as endpoint for Remoting Calls from Flash player. In order to use a php file as a service we need to include it in the gateway.php file. Now if you have two php files exposed as services the gateway.php file has a code snippet similar to:

require_once 'Zend/Amf/Server.php';

require_once 'a.php'; require_once 'b.php';

$server = new Zend_Amf_Server(); echo $server->handle();

where a.php & b.php are service php files.

Now if a.php is invalid (syntactical errors etc.) the user is not allowed to invoke the functions of even b.php, since the gateway.php file could not include the invalid a.php file and hence throws an error. This is a concern as the user will now have to make sure that all the files exposed as services need to be valid all the time.

Is there any other better way of exposing the service php files so that the above limitations don't show up.

Comments

I don't think there's something specific to AMF - if you load bad file, PHP stops execution and produces an error. There's little that can be done about it. However, in this particular case you could use autoloading and then when you run service from a.php you would not need to include b.php. Thus, only service using b.php would be broken when b.php is broken.

The problem is in cases where the files are located in separate directories, say, 'dir1/a.php' and 'dir2/b.php' Now to expose these services we will have to write a code which will include $server->setClass('a') & $server->setClass('b'). If we use __autoload function, firstly how will we resolve the complete path to the php files and secondly, it will still result in errors as soon as we call setClass()

I'm not sure I understand - could you provide complete code example (maybe by mail to stas@zend.com) that describes what problems you get with autoloading?

This looks like an issue that has been resolved. Are you having the issue with Zend Framework 1.7.8?

fixed