First of all, create the directory:
mkdir library/Amz
Then add a line to the config file (application/configs/application.ini). Since the library name won't be different between stages, I've put it in the base section (production):
[production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" autoloadernamespaces.amz = "Amz_" [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1
It is very important to note 2 things:
1. I had to add something (doesn't matter what) after autoloadernamespaces. If I would have written 'autoloadernamespaces = "Amz_"', this would have yielded errors since an array is expected. By adding the ".amz" your making autoloadernamespaces into an array.
2. Instead of just "Amz" for my class prefix, I've added "Amz_". The reason for this is to avoid that "Amz111_" would also be accepted for my classes.
First time I tried adding my library I ran into both of these issues.
You might remember that in the virtual host we set up in the previous post, that we set the "APPLICATION_ENV" environment variable to development. Well, it comes into play here as well. APPLICATION_ENV decides what part of the config is loaded, so in our case it's the development part. When later on you set up your production environment, you set the variable to "production" and automatically it will use your production config. This enables you to have the same code on all your environments without the hastle of copying/modifying ini files liek in the old days.
No comments:
Post a Comment