简体   繁体   English

确定在mod_perl下运行的Catalyst应用程序的应用程序目录

[英]Determine application directory of Catalyst application running under mod_perl

When running under mod_perl Cwd's getcwd returns / When using Mojolicious, I can simply put $self->app->home in any controller to determine the absolute path to the base directory in which the application runs. 当在mod_perl下运行时,Cwd的getcwd返回/当使用Mojolicious时,我可以简单地将$self->app->home放在任何控制器中,以确定运行应用程序的基本目录的绝对路径。

Is there something similar in Catalyst? Catalyst中有类似的东西吗?

Regards, ldx 问候,ldx

Catalyst has $c->path_to( 'something' ) , so you can directly ask it to give you a path to a file or resource. Catalyst有$c->path_to( 'something' ) ,所以你可以直接让它给你一个文件或资源的路径。

Alternatively, you could use $c->config->{ home } to get your root directory. 或者,您可以使用$c->config->{ home }来获取根目录。 But that seems a bit hackish and is not guaranteed to work with the next release of Catalyst. 但这似乎有些过时,并不能保证与下一版Catalyst一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM