php Laravel 基本路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14631436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:39:36  来源:igfitidea点击:

laravel base path

phplaravel

提问by ebelendez

Im using URL::base(); and I get this URL:

我使用 URL::base(); 我得到这个网址:

http://www.kp.com.mx/sis_colgate/public

but what I need is this complete path:

但我需要的是这个完整的路径:

/home/belendez/public_html/sis_colgate/public

Does anybody knows how can I get that path? Thanks

有谁知道我怎样才能得到那条路?谢谢

回答by Deinumite

What you want to use is the pathhelper.

您要使用的是path助手。

The URL helper is for generating HTTP URLs.

URL 助手用于生成 HTTP URL。

Try the path('public')function in Laravel 3,

试试path('public')Laravel 3 中的功能,

or the public_path()function in Laravel 4.

public_path()Laravel 4 中的函数。

Edit: Updated with answer for Laravel 4, thanks Erin

编辑:更新了 Laravel 4 的答案,感谢 Erin

回答by yesnik

Laravel has helpersfor paths:

Laravel 有路径助手

base_path();    // '/var/www/mysite'
app_path();     // '/var/www/mysite/app'
storage_path(); // '/var/www/mysite/storage'

回答by Dimi Mikadze

you can find info about paths in documentation:

您可以在文档中找到有关路径的信息: