Laravel:如何包含一个库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16833310/
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-09-14 07:49:59  来源:igfitidea点击:

Laravel: how to include a library?

phpcross-browserlaraveluser-agent

提问by dflow

I want to use the following : Holmes in the library folder:

我想使用以下内容:库文件夹中的福尔摩斯:

http://paste.laravel.com/Em

http://paste.laravel.com/Em

    // Determine if request is from a mobile device
Holmes::is_mobile(); // returns boolean

// Determine the type of device
$device = Holmes::get_device(); // returns string

// Determine if a specific device is being used
// Any supported device below is acceptable
// lowercased no spaces, obviously. <3
Holmes::is_ipad();
Holmes::is_blackberrytablet();

Where do i place what?

我把什么放在哪里?

in the route:?

在路线:?

View:

看法:

@if(Holmes::is_iphone())
{{ 'this is an iphone' }}
@endif

I get also this error: Only variables should be passed by reference on line 25 in the Holmes library file

我也收到这个错误:只有变量应该在 Holmes 库文件的第 25 行通过引用传递

I'm trying to transit from procedural mess ;)

我正在尝试从程序混乱中过渡;)

回答by sarunast

There is a great articlewith instructions on how to load a library in Laravel 4by Chris Fidao (Fideloper):
http://fideloper.com/laravel-4-application-setup-app-library-autoloading

Chris Fidao (Fideloper)有一篇很棒的文章,其中介绍了如何在Laravel 4 中加载库:http://fideloper.com/laravel-4-application-setup-app-library-autoloading