The Zym_App component in short is a generic
configurable bootstrapping API. It was created from the
Zend_Application proposal by Bill Karwin
to solve the problem of bootstrapping applications. Most applications
have similar bootstraps; however, developing a component that is flexible
yet simple is not easy. Zym_App
follows a convention over configuration
design paradigm. If you follow Zym's conventions, everything will work
out of the box and other developers working on the same project
can jump in knowing almost everything they need and reducing development time
wasted on learning the flow of a project. Although having a convention
is good, sometimes developers need to break them, for this reason, flexibility
was an important aspect in the design of this component.
Almost every aspect of Zym's convention can be changed through
configuration (directory structure, config structure etc..).
This component benefits developers by reducing the setup time of projects
and provides a logical convention allows other developers to join development
without having to learn the differences in design of an application.
The way Zym_App works is that it dispatches
what we call "resources". Instead of building one "God" class that
does bootstrapping, we modularised it into resources. This is not a proper
name for them, but the name was kept from the proposal it was derived from.
The component itself implements the singleton pattern and works very similar
to the front controller.
2.1. Environments
Through out the life cycle of an application, it will go through
several phases (Most common are development, production and testing).
Environments allow you to configure an application specific for each phase
specific phase.
Zym_App has several constants for the supported
environments that all its resources are catered to. Although we cater
specifically to these environments, it does not restrict you from
creating your own environment. An example of a custom environment
would be a "cli" environment used for cli tools.
Zym_App::ENV_DEFAULT - Contains the default config of every other environment (mostly internal use)
Zym_App::ENV_DEVELOPMENT - Development environment, most resources enable debugging features
Zym_App::ENV_PRODUCTION - Production environment, most resources enable caching and disable error reporting
Zym_App::ENV_TEST - Testing environment, useful for running tests
Example 2.1. Setting an environment
Setting an environment can be done using setEnvironment()
as long as it is done before dispatch()
or run().