Catalyst requires components, gather these components to use Catalyst.
use Catalyst qw/PickComponents/;
The configuration can be set up using paths and modules to be loaded and expected paths and modules. The following configuration is an example:
__PACKAGE__->config->{pick_components} = {
paths => [ '::Controller', '::Model' ],
modules => [ 'MyApp::View::TT' ],
expect_paths => [ '::Controller::Admin', '::Controller::Search' ],
expect_modules => [ 'MyApp::Controller::Admin', 'MyApp::Controller::Search' ],
}
Alternatively, you can set up the configuration in YAML files such as myapp.yml or myapp_local.yml:
pick_components:
paths:
- ::Controller
- ::Model
modules:
- MyApp::View::TT
expect_paths:
- ::Controller::Admin
- ::Controller::Search
expect_modules:
- MyApp::Controller::Admin
- MyApp::Controller::Search
The plugin provides developers with the option to choose which modules to load for their specific server instance. In cases where Perl modules expand quickly, it becomes necessary to load different modules into different servers to ensure high performance. The plugin makes it easier to maintain and configure large projects by eliminating the need to remove modules for each server.
You can experiment with various configurations for different server instances by using the different paths and modules to be loaded and expected paths and modules options. The following snippets illustrate how the configuration can be set up in myapp_local.yml for different servers:
pick_components:
paths:
- ::Controller
- ::Model
modules:
- MyApp::View::TT
expect_paths:
- ::Controller::Admin
- ::Controller::Search
expect_modules:
- MyApp::Controller::Admin
- MyApp::Controller::Search
pick_components:
paths:
- ::Controller::Search
- ::Model
modules:
- MyApp::View::TT
- MyApp::Controller::Search
- MyApp::Controller::Root
expect_paths:
- ::Controller::Admin
expect_modules:
- MyApp::Controller::Admin
pick_components:
paths:
- ::Controller::Admin
- ::Model
modules:
- MyApp::View::TT
- MyApp::Controller::Admin
- MyApp::Controller::Root
expect_paths:
- ::Controller::Search
expect_modules:
- MyApp::Controller::Search
Overall, Catalyst::Plugin::PickComponents is a convenient plugin to use when dealing with large web applications with many components. The process of selecting which modules to load for different server instances is simplified and makes it easy to maintain project configurations.
Version 0.02: N/A