NAME

Gears - A framework to build web frameworks

SYNOPSIS

# Create an application
package My::App;
use Mooish::Base;
extends 'Gears::App';

# Build routes and components
sub build ($self)
{
	$self->load_controller('User');
	$self->load_controller('Blog');
}

# Using this package
use Gears qw(load_component get_component_name);

my $class = load_component('MyApp::Component::Session');
my $name = get_component_name('Session', 'MyApp::Component');

DESCRIPTION

Gears is a toolkit for building web frameworks. It provides the essential building blocks needed to create structured web applications: an application container (Gears::App), a component system with lifecycle hooks (Gears::Component), controllers (Gears::Controller), routing (Gears::Router), configuration management (Gears::Config), templating (Gears::Template), logging (Gears::Logger), request context handling (Gears::Context) and more.

The framework is designed to be flexible and extensible. Rather than being a complete web framework itself, Gears gives you the tools to build your own framework with the features and opinions you need. All components follow a consistent pattern and can be extended or replaced.

The base Gears module provides utility functions, which are not limited to being used internally by the framework.

Stability notice

Gears is currently in a beta phase and will stabilize on version 1.000. Until then, no stability promises are made and everything is up for changing.

INTERFACE

This package uses exporter and imports no symbols by default.

load_component

my $class = load_component($package);

Loads a component class if it hasn't been loaded yet and returns the package name. Uses a state cache to ensure each package is only loaded once.

If the package already has a new method available, it assumes the package is already loaded and skips loading. This optimization avoids unnecessary loads and the dependency on Class::Inspector.

Returns the package name after ensuring it's loaded.

get_component_name

my $name = get_component_name($package, $base);

Glues a name of a component which is a subclass of $base. $package will be joined together with $base to form a full namespace, allowing short names of the components to be used, for example in configuration. If $package starts with ^ character, then $base will not be included in the final component name at all.

SEE ALSO

Thunderhorse

AUTHOR

Bartosz Jarzyna <bbrtj.pro@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2025 by Bartosz Jarzyna

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.