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.

Comments

  1. taufik

    17 Juil 11

    Can you give an example of mysql database crud operations ?

    Thanks

Laissez un commentaire

Événements à venir / Upcoming Events

  1. Silex Labs Apéropensource #44 – Edition du mois de Septembre

    28 septembre @ 19:00 - 22:00
  2. Atelier SQL : Découverte du SQL avec MySQL

    3 octobre @ 19:00 - 21:00
  3. NodeJS, je commence où ?

    19 octobre @ 19:00 - 21:00

News letter

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

Silex Labs community Tweets

Facebook page

Abonnez-vous aux news via Email

Rejoignez 45 autres abonnés