Recent from talks
Contribute something
Nothing was collected or created yet.
Catalyst (software)
View on WikipediaThis article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
| Catalyst | |
|---|---|
![]() | |
| Original author | Sebastian Riedel |
| Stable release | 5.90131
/ 20 July 2023[1] |
| Written in | Perl |
| Type | Web application framework |
| License | PAL and GPL |
| Website | http://catalyst.perl.org/ |
Catalyst is an open-source web application framework written in Perl. It closely follows the model–view–controller (MVC) architecture and supports a number of experimental web patterns. It is written using Moose, a modern object system for Perl. Its design is heavily inspired by frameworks such as Ruby on Rails, Maypole, and Spring.
Catalyst can be used by web application developers to deal with code common to all web applications. It provides an interface for receiving page requests, dispatching page requests into developer-written code to process, and return of the requests. Catalyst also provides a standardised interface for data models, authentication, session management and other common web application elements.
All of these elements are implemented as plugins to a set of common interfaces, allowing the developer to change the specific method used (e.g. a session storing in shared memory versus as a database table, or using FastCGI versus operating as an within Apache's mod_perl) by changing the configuration of Catalyst to use a different plugin without altering the application code.
Catalyst is primarily distributed through the CPAN, which is the official distribution channel for Perl libraries and applications.
History
[edit]Maypole was one of the first web application frameworks for the Perl programming language that was based on the MVC pattern; its principal author was Simon Cozens.[2] Catalyst started as a fork of Maypole, intended to become Maypole 3.0.[3] Development ceased on Maypole, however, with its most recent release in April 2008,[4] and Catalyst became its modern supported equivalent.
The first development release of Catalyst took place on 28 January 2005. The first official version was published on CPAN on 16 February 2005.[5] As of June 2011, Catalyst had 201 registered contributors.[6]
Philosophy
[edit]Catalyst is based on the "don't repeat yourself" (DRY) principle, which means that definitions should only have to be made once. Catalyst can be used with automatic class loading from the database through one of the many loader modules, thus requiring no code for the database layer. But, if you require the flexibility of manually doing everything, it's also an option. Another guiding principle of Catalyst is flexibility.
Catalyst promotes the re-use of existing Perl modules that already handle common web application concerns well.
- The Model part is handled through DBIx::Class, Plucene, Net::LDAP and other model classes.
- The View layer is usually handled by Template Toolkit, Mason, or HTML::Template, among others.
- The Controller layer is of course written by each application author. Large chunks of Controller functionality can usually be deferred to one of the many Catalyst plugins (e.g., Catalyst::Plugin::FormValidator, Catalyst::Plugin::Prototype, Catalyst::Plugin::Account::AutoDiscovery, etc.).
- Finally, Catalyst offers a set of helpers to simplify flow control and mapping URLs to controller methods.
Catalyst has a large selection of plugins.[7] For example, it has JavaScript generation for Ajax and RIAs using the Catalyst::Plugin::Prototype module (prototype is an Ajax framework). Plugins cover many areas, for example authentication, session management, HTTP negotiation and REST.
Catalyst can also be used with other Ajax frameworks such as jQuery or YUI, the Yahoo! User Interface Library.
Web server support
[edit]For development and testing, Catalyst has a built-in simple HTTP server. For production use, Apache, lighttpd, Hiawatha, Cherokee or Nginx with FastCGI or mod_perl support is recommended, but any web server with CGI or FastCGI support will work. On Apache, mod_perl can help with performance considerably, though its use might be an issue because it can be unsafe to share multiple applications under mod_perl.
Since early 2008, Catalyst applications can also be deployed using the HTTP::Prefork engine[8] which provides for the deployment of high performance Catalyst applications without a separate web server. Starting with the release of Catalyst 5.9, Catalyst also outputs to the PSGI spec thus it can be run on any Plack server and along with any server or protocol that supports the PSGI spec, including Mongrel2.
Database support
[edit]Catalyst can run using any database supported by Perl's DBI (this means almost anything, even a CSV file), but a proper RDBMS or ODBMS is recommended. The database access is entirely abstracted from the programmer's point of view and Catalyst, through one of its model classes, handles access to all databases automatically – though, if needed, using direct SQL queries is possible. This enables database-neutrality, application portability over different database systems, and usability of pre-existing databases for Catalyst application development as much as possible, though due to different feature sets of the RDBMSes, it is not completely guaranteed by the framework alone. Several different RDBMS systems are supported, including MySQL, PostgreSQL, SQLite, IBM Db2, Oracle and Microsoft SQL Server. For ODBMSes, there is explicit support for KiokuDB via Catalyst::Model::KiokuDB.[9] The Model abstraction allows databases of any nature to be accessed via Catalyst::Model::Adaptor.[10]
Many Catalyst-based projects use DBIx::Class as the ORM layer, which provides further abstraction of SQL queries, using a resultset-based API with transparent support for arbitrary joins and other features.
Uses
[edit]Websites powered by Catalyst include Magazines.com,[11] bbc.co.uk iPlayer backend,[12] DuckDuckGo's Community Platform, http://flexibase.io and Tripwolf.com. The MojoMojo wiki engine is written using Catalyst.[13]
See also
[edit]References
[edit]- Diment, Kieren (8 July 2009). The Definitive Guide to Catalyst. Apress. ISBN 978-1-4302-2365-8. Archived from the original on 17 September 2009. Retrieved 9 September 2009.
- ^ "CPAN Module Release". Catalyst. Retrieved 15 August 2024.
- ^ Simon Cozens (22 April 2004). "Rapid Web Application Deployment with Maypole". Perl.
- ^ The Definitive Guide to Catalyst. Apress. September 2009. p. 2. ISBN 978-1430223658.
- ^ "Maypole". CPAN.
- ^ "Catalyst Changes file". Retrieved 8 August 2018.
- ^ "Catalyst Framework - Contributors". Ohloh. Retrieved 6 June 2011.
- ^ "Search for "Catalyst::Plugin::" - metacpan.org". metacpan.org. Retrieved 8 August 2018.
- ^ "Catalyst::Engine::HTTP::Prefork - High-performance pre-forking Catalyst engine - metacpan.org". metacpan.org. Retrieved 8 August 2018.
- ^ "Catalyst::Model::KiokuDB - use KiokuDB in your Catalyst apps - metacpan.org". metacpan.org. Retrieved 8 August 2018.
- ^ "Catalyst::Model::Adaptor - use a plain class as a Catalyst model - metacpan.org". metacpan.org. Retrieved 8 August 2018.
- ^ ""Catalyst/DBIC/eCommerce Developer job" posting". 8 May 2011. Archived from the original on 13 May 2011. Retrieved 6 June 2011.
- ^ "BBC's iPlayer is powered by a Perl software stack (including Catalyst)".
- ^ Diment, Kieren; Trout, Matt S (2009). "Catalyst Cookbook". The Definitive Guide to Catalyst. Apress. pp. 278–281. ISBN 978-1-4302-2365-8.
- ^ "Biggest porn site on the web YouPorn powered by Perl/Catalyst (top 50 in alexa)". reddit.
- ^ "YouPorn software stack was originally written in Perl + Mysql". 2 April 2012.
External links
[edit]Catalyst (software)
View on Grokipediacatalyst.pl to streamline setup.[1] Its comprehensive manual and tutorial resources further support developers in building robust applications, positioning Catalyst as a enduring choice in the Perl ecosystem despite the rise of newer languages.[4]
Overview
Core Architecture
Catalyst employs the Model-View-Controller (MVC) pattern as its foundational architecture, separating application logic into distinct components to enhance maintainability and scalability in Perl web development. In this structure, Models manage data and business logic, Views handle presentation and rendering, and Controllers process user requests and orchestrate interactions between Models and Views. Catalyst's dispatcher plays a central role by matching incoming HTTP requests to appropriate Controller actions based on URL paths, HTTP methods, and other criteria, ensuring efficient request routing without rigid conventions.[5] The request cycle in Catalyst begins with the engine receiving an HTTP request, which triggers the creation of a Catalyst context object that encapsulates the request, response, configuration, log, and a shared stash for data passing between components. This context is then passed to the dispatcher, which executes a sequence of phases: an optionalbegin action for initialization, an auto action for per-controller setup, the matched Controller action(s), and finally an end action for cleanup and response finalization. During this cycle, actions can forward control to other components using methods like $c->forward or detach with $c->detach, allowing modular handling while maintaining the context's state throughout. The cycle concludes with the engine generating the HTTP response, including headers and body, via the $c->finalize method.[1]
Catalyst integrates Moose, Perl's modern object-oriented system, to provide robust features for component definition, such as attributes, roles, and inheritance, enabling developers to extend classes like Catalyst::Controller with use Moose; extends 'Catalyst::Controller';. This integration, prominent in the 5.x series, supports type constraints and lazy building for efficient object management. A key concept is the Catalyst context ($c), a blessed object that propagates data via its stash hashref, accessible across Models, Views, and Controllers to facilitate seamless communication without global variables. Additionally, action chaining allows modular request handling by defining sequential actions linked via the :Chained attribute, where each action in the chain receives the context and can capture path parts, promoting reusable URL structures like /catalog/*/item/*.[1][5]
The 5.x series of Catalyst emphasizes a lightweight and extensible design, relying minimally on external dependencies beyond essential Perl core modules and select CPAN utilities like Moose for its object system, while promoting the reuse of existing Perl modules for specialized tasks to avoid bloat. This approach ensures the framework remains flexible for integration with various web servers and avoids imposing unnecessary abstractions, allowing developers to focus on application-specific logic.[5]
Licensing and Compatibility
Catalyst is free software, released under the same terms as Perl itself: dual-licensed under the GNU General Public License version 2 or later, and the Artistic License version 2.0.[6] It requires Perl 5.8.3 or later and is compatible with modern Perl versions, including Perl 5.40 as of November 2025. The framework supports integration with various web servers via engines like Catalyst::Engine::HTTP and, since version 5.90000, with PSGI/Plack for enhanced interoperability.[6]History and Development
Origins and Early Releases
Catalyst originated as a fork of the Maypole framework in 2005, driven by developers who sought greater flexibility in Perl web development to support a broader range of applications beyond Maypole's primary focus on CRUD operations for database-driven sites.[2] The first public release appeared on January 28, 2005, with the official version 1.0 following shortly after on February 16, 2005. Early inspirations for Catalyst included Ruby on Rails for its emphasis on rapid prototyping and convention-over-configuration approach, the Java Spring framework for enterprise-level patterns like dependency injection and aspect-oriented programming, and Maypole itself for Perl-specific MVC conventions.[2] Development proceeded under a model of rapid iteration during its initial phase, with the core API achieving stability by mid-2005; Maypole's final update in April 2008 further underscored Catalyst's emergence as an independent project.[2] By 2006, Catalyst had fully integrated its plugin system, which enabled modular extensions and drew early adopters from the Perl community seeking extensible web solutions.[2]Major Milestones and Recent Updates
Catalyst version 5.8, released in 2009, marked a significant advancement by establishing a stable plugin ecosystem that enhanced the framework's extensibility for web application development.[7] This release solidified Catalyst's modular design, allowing developers to integrate reusable components more reliably for tasks such as authentication, caching, and session management. By June 2011, the project had grown to include 201 contributors, underscoring the expanding community involvement in its evolution.[1] In 2011, version 5.9 introduced native PSGI support, enabling compatibility with the Plack toolkit and facilitating deployment on modern asynchronous web servers.[5] This PSGI integration represented a key evolutionary shift in Catalyst, moving away from its earlier reliance on mod_perl environments toward more flexible, event-driven serving options via PSGI/Plack. The core runtime has remained stable, with the latest release at version 5.90132 in November 2024, focusing on refinements rather than major overhauls.[8] Ongoing maintenance occurs through the Comprehensive Perl Archive Network (CPAN), emphasizing security enhancements and compatibility with recent Perl versions, including Perl 5.40.[3] In August 2025, the Catalyst::Authentication::Credential::HTTP plugin reached version 1.019, resolving CVE-2025-40920 by replacing the insecure Data::UUID library for nonce generation with Crypt::SysRandom to ensure cryptographically secure random values.[9] This patch highlights the continued priority on security in the ecosystem, particularly for authentication mechanisms in production environments.[10]Design Philosophy
Fundamental Principles
Catalyst's design is fundamentally guided by the "Don't Repeat Yourself" (DRY) principle, which emphasizes writing code once and reusing it to avoid redundancy. This is achieved by eschewing built-in features for common tasks, instead encouraging integration with established Perl modules from the CPAN ecosystem, such as DBIx::Class for object-relational mapping rather than a proprietary ORM. By leveraging these mature libraries, developers can define functionality in a single place, ensuring consistency and reducing maintenance overhead across applications. A key tenet is flexibility over rigid conventions, distinguishing Catalyst from more opinionated frameworks like Ruby on Rails. Developers retain broad choice in selecting components, configurations, and dispatching logic, allowing customization to fit diverse project needs without prescriptive defaults. This approach empowers programmers to tailor the framework—such as choosing URL dispatching methods or home directory paths—while maintaining a clean, modular structure. For instance, Catalyst avoids mandating specific tools, permitting the use of Template Toolkit for view rendering or LWP::UserAgent for HTTP interactions, thereby promoting adaptability in web application development.[11][12] The reuse philosophy extends this by deeply integrating with the Perl ecosystem, focusing the core on the essential request-response cycle while delegating specialized tasks to plugins and external modules. Catalyst is explicitly not a "kitchen sink" framework; it avoids bloat by keeping the minimal core lightweight and extensible only through optional, targeted plugins, ensuring efficiency and preventing unnecessary dependencies. This design choice aligns with the broader goal of rapid, scalable development without imposing a one-size-fits-all solution.[1][11] Testability is another core principle, embedded directly into the framework to facilitate reliable development practices. Catalyst includes a built-in development server that enables unit testing of applications without requiring external web servers or complex setups, allowing developers to simulate HTTP requests and verify behavior in isolation. Combined with integrated logging and automated test generation during application scaffolding, this supports iterative testing and debugging, reinforcing the framework's commitment to maintainable, high-quality code.[11][13]Modularity and Extensibility
Catalyst achieves extensibility primarily through its plugin system, which allows developers to enhance the framework's core functionality without altering the base code. Plugins are distributed via CPAN and loaded directly in the application's configuration using theuse Catalyst statement, omitting the Catalyst::Plugin:: prefix—for instance, use Catalyst qw/[Authentication](/page/Authentication)/; incorporates the Catalyst::Plugin::Authentication module for user authentication support. These plugins leverage Moose roles to inject methods and behaviors into the application's context object, enabling seamless integration and extension of capabilities such as session management or caching.[1]
The framework's modularity is further supported by treating controllers, models, and views as interchangeable Perl classes that can be customized and swapped as needed. Developers create these components using Catalyst's helper scripts, such as script/myapp_create.pl model MyDatabase DBIC::Schema for a database model or view MyTemplate TT for a Template Toolkit view, allowing for flexible composition of application logic. URI dispatching is handled through action attributes in controllers, which define how requests map to specific methods, while action roles provide additional behaviors like validation or authorization without hardcoding them into the core classes.[1]
Key extensibility features include chained actions for handling complex routing scenarios and a centralized context object for accessing application state. Chained actions enable hierarchical URL structures by linking methods with attributes like :Chained('/') PathPart('foo'), allowing developers to build nested paths such as /foo/1/bar for dynamic dispatching. The context object, accessible as $c, serves as a global hub for request ($c->req), response ($c->res), and stash ($c->stash) data, facilitating forwarding between components and URI generation with methods like $c->uri_for.[1]
As of 2025, several hundred Catalyst-specific plugins are available on CPAN, covering areas such as authentication, sessions, and caching, which underscores the framework's vibrant ecosystem. This abundance enables easy integration with external tools, including wrapping non-Perl services through custom plugins that interface with APIs or middleware like PSGI for deployment flexibility.[14][15]
Key Components
Model-View-Controller Implementation
Catalyst implements the Model-View-Controller (MVC) pattern by defining distinct roles for each component, allowing developers to separate concerns in web application development. The Controller serves as the entry point for handling incoming HTTP requests, processing user input, and directing the application flow. It achieves this through actions, which are methods within controller classes marked with attributes to match URL paths or regular expressions. For instance, an action defined with the:Local attribute responds to requests at a path relative to the controller's namespace, while :Path allows explicit path specification.[12][16]
Controllers support key methods for response handling and flow control. The end() method, typically marked as :Private, is invoked automatically at the conclusion of the request cycle to finalize responses, such as rendering output or setting headers. The forward() method enables chaining by passing control to another action or component while preserving the execution context, allowing sequential processing without altering the URL. In contrast, detach() terminates the current chain and prevents further execution, useful for early exits like error handling or redirects. These mechanisms facilitate modular request dispatching.[12][16]
The Model layer in Catalyst remains agnostic to the framework's web-specific aspects, focusing solely on data logic and business rules without built-in persistence mechanisms. Developers typically integrate object-relational mappers (ORMs) such as DBIx::Class for database interactions or plain DBI for direct SQL queries, inheriting from the Catalyst::Model base class to leverage component lifecycle methods like configuration and instantiation. This separation ensures models can be reused independently of the web context.[12][17]
Views handle the rendering of data into user-facing output formats, configurable on a per-action basis through the controller's forwarding logic. Common implementations use Template Toolkit for HTML generation or JSON::XS for API responses, inheriting from Catalyst::View to provide a standardized process() method that populates the response body from the shared stash. The base class simplifies setup by automating template resolution based on action names or stash variables.[12][18]
Interactions among MVC components occur via the central context object, denoted as $c, which encapsulates the request, response, and a shared stash for passing data between layers. Controllers populate the stash with model-retrieved data, which views then consume for rendering, while methods like forward() and detach() operate within this context to maintain state across the request lifecycle. This design promotes parallel development, as teams can work on models, views, and controllers independently, with base classes like Catalyst::Model and Catalyst::View streamlining integration and reducing boilerplate code.[12]
Plugins and Reusable Modules
Catalyst::Plugin::Authentication provides infrastructure for handling user authentication in Catalyst applications, supporting both verification of user identity and session management for logged-in users.[19] It enables the definition of authentication realms, which combine credential checkers and user stores to validate and persist user data across requests.[19] A key component is Catalyst::Authentication::Credential::HTTP, which integrates HTTP-based authentication methods like Basic and Digest, allowing seamless use with Catalyst::Plugin::Authentication.[20] In August 2025, version 1.019 of Credential::HTTP was released to address CVE-2025-40920 by replacing Data::UUID with Crypt::SysRandom for secure nonce generation, mitigating predictable authentication challenges.[21] Catalyst::Plugin::Session manages client-side state and server-side storage for session data, ensuring secure persistence of user information between requests.[22] Released in September 2025, version 0.44 fixed CVE-2025-40924 by adopting Crypt::SysRandom for generating cryptographically secure session IDs, replacing the previous insecure method based on SHA-1 hashing of predictable values.[23][24] Among commonly used reusable modules, Catalyst::Plugin::Cache enhances application performance by implementing a flexible caching layer that supports multiple backends, such as memory or file-based stores, to reduce redundant computations and database queries.[25] For view rendering, Catalyst::View::TT serves as a Template Toolkit integration, allowing developers to generate dynamic HTML and other outputs using TT templates within the Catalyst MVC structure.[26] Database interactions are facilitated by Catalyst::Model::DBIC::Schema, which connects Catalyst models to DBIx::Class schemas, enabling object-relational mapping for efficient data handling without direct SQL in controllers.[27] Plugins and modules are installed via CPAN tools like cpanm, after which they are loaded in the application's main module by including their names (without the Catalyst::Plugin:: prefix) in theuse Catalyst statement.[1] Configuration occurs in the application's config file, typically YAML or Perl format; for instance, authentication realms are defined under the authentication key, specifying credential and store classes like:
authentication:
default_realm: users
default_realm:
credential:
class: HTTP
type: basic
store:
class: Minimal # or DBIx::Class, etc.
authentication:
default_realm: users
default_realm:
credential:
class: HTTP
type: basic
store:
class: Minimal # or DBIx::Class, etc.
session section.[22]
Catalyst plugins adhere to Moose object-oriented best practices, leveraging roles and attributes for composable, extensible behavior in components.[28] They can be searched on MetaCPAN using the Catalyst::Plugin:: prefix to discover available extensions.[1]
Deployment Options
Web Server Integration
Catalyst provides a built-in development server based on PSGI (using HTTP::Server::PSGI), which is intended for testing and debugging applications during development. This server can be started via the commandscript/myapp_server.pl, typically running on port 3000, and supports features like automatic reloading of code changes with the -r flag.[1][29]
For production deployment, Catalyst supports FastCGI, which enables persistent processes to handle multiple requests efficiently on web servers such as Apache and Nginx. FastCGI is launched using script/myapp_fastcgi.pl with options like -l for the listen socket (e.g., /tmp/myapp.socket) and -n to specify the number of processes (e.g., 5). For Apache, configuration can use a .htaccess file with directives such as AddHandler fastcgi-script .fcgi and a RewriteRule to route requests to the FastCGI script. On Nginx, a location block example includes fastcgi_pass unix:/tmp/myapp.socket; along with fastcgi_param SCRIPT_NAME /myapp;.[30]
mod_perl integration with Apache is a legacy production option, primarily for versions of Catalyst prior to 5.9. In modern deployments (5.9+), use PSGI via Plack::Handler::Apache2 or equivalent adapters for compatibility with Apache 2.4 (Apache 1.3 is end-of-life since 2010 and not recommended).[31][32]
Since version 5.9, Catalyst has supported the PSGI specification through the Catalyst::PSGI module, allowing deployment as a PSGI application on modern Perl servers like Starman, uWSGI, or others via Plack adapters. This enables asynchronous request handling and compatibility with a wide range of servers, replacing legacy engines like CGI or FastCGI in many cases. PSGI is recommended for production scalability over older methods like mod_perl due to its portability and shared middleware ecosystem. Engine selection, including PSGI, can be influenced by environment variables or application configuration in myapp.conf.[33]
Database and Storage Support
Catalyst provides database support through the Perl Database Interface (DBI), enabling integration with any DBI-compliant relational database such as MySQL, PostgreSQL, and SQLite, without incorporating native SQL handling within the framework itself.[34] This agnostic approach allows developers to leverage existing DBI drivers for connectivity, ensuring broad compatibility across various database systems.[27] For object-relational mapping (ORM), Catalyst primarily utilizes DBIx::Class, configured via the Catalyst::Model::DBIC::Schema module, which generates schema classes and result sets for data access.[27] Setup involves creating a model with a helper script that specifies the schema class and connection details, such asscript/myapp_create.pl model DB DBIC::Schema MyApp::Schema::DB dbi:SQLite:mydb.db.[27] This integration delegates SQL generation and querying to DBIx::Class, promoting separation of concerns in the model layer.[35]
Alternative storage options extend beyond relational databases, supporting object-oriented persistence with systems like KiokuDB for non-relational data through dedicated models such as Catalyst::Model::KiokuDB.[36] File-based or in-memory storage is facilitated via plugins, including Catalyst::Plugin::Session::Store::File for simple file-backed caching and Catalyst::Plugin::Session::Store::Cache for memory-resident data handling.
Connection management is handled through configurable Data Source Names (DSNs) defined in the application's configuration file, typically as a hash reference with keys for DSN, username, password, and additional options.[27] Transaction handling is delegated to the underlying modules, such as DBIx::Class's txn_do method for atomic operations or KiokuDB's scope guards for object persistence.[27][36]
Catalyst applications commonly mix multiple storage backends, allowing relational data via DBIx::Class alongside non-relational or in-memory components for optimized performance in diverse scenarios.

