https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25586

--- Comment #13 from David Cook <[email protected]> ---
Locally, I've created a Koha::Prosentient::Setup::Home module which dynamically
finds the "Koha Home":

#NOTE: See Catalyst->setup_home()
#NOTE: See Mojo::Home->detect()
sub detect {
    my ( $class, $home ) = @_;

    my $env_var = $ENV{KOHA_HOME};
    if ($env_var) {
        $home = $env_var;
    }

    if ( !$home ) {
        my $koha_logical_root = File::Spec->catdir(
            File::Basename::dirname(__FILE__),
            File::Spec->updir,
            File::Spec->updir,
            File::Spec->updir,
            File::Spec->updir
        );
        my $koha_real_root = Cwd::realpath($koha_logical_root);
        if ( -d $koha_real_root ) {
            $home = $koha_real_root;
        }
    }

    return $home;
}

Using Koha::Prosentient::Setup::Home->detect(), I find the application
root/home, and then I can manipulate the @INC using "use lib @local_libs" to do
things like add a directory for Koha modules at a system level (modules
provided by Debian packages) and a directory for instance level Koha modules. 

I use Koha::Prosentient::Setup early in plack.psgi before any Koha-specific
module is called, so that I can manipulate the @INC early and thus have my
local modules loaded first, which allows me to override Koha modules or add
extra Koha modules - which is especially useful when using things like
Module::Pluggable.

In the longer term, I think these would be wise additions to upstream Koha, as
they'll make it easier to do local customisations/extensions while preserving
core Koha. 

And it all comes back to a concept of "home" or "application root".

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to