Best Practices for Long Term Projects

In the distribution there is a folder called « Amfphp ». This is the main one, containing the code that you will actually use. For small projects that won’t last long, you can just add your service classes to the « Services » folder. There is however a problem with this approach: There is not a clear separation between your code and the Amfphp folder. This means for example that you need to be careful when upgrading.

If you would like to have a better separation, we suggest you take the time to change the configuration and make your own gateway PHP script. You can find an example in Examples/Php/index.php

With the default gateway and configuration amfphp looks for its configuration in Amfphp/Config, its plugins in Amfphp/Plugins, and services in Amfphp/Services. You can make your own gateway script outside Amfphp, as well as a custom config class pointing to a custom plugins folder and a custom service folder.

In this script for example you would put:

$myConfig = new MyConfig();
$gateway = Amfphp_Core_HttpRequestGatewayFactory::createGateway($myConfig);

in MyConfig you would do something like the following:

$this->serviceFolderPaths [] = dirname(__FILE__) . "/MyServices/";
$this->pluginsFolder = dirname(__FILE__) . "/Plugins/";

In this way if you need to upgrade Amfphp, you can just overwrite the old Amfphp folder with the new one.

We particularly recommend this approach for frameworks integrating Amfphp.


  1. taufik

    17 Juil 11

    Can you give an example of mysql database crud operations ?


Laissez un commentaire

News letter

Evénements Silex Labs sur Paris et sa région: Inscrivez vous à la Newsletter mensuelle

Silex Labs community Tweets

Facebook page