Laravel 4 使用供应商类 [英] Laravel 4 using vendor classes

查看:33
本文介绍了Laravel 4 使用供应商类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 3 后安装了 Laravel 4,喜欢它.我以前可以这样使用 Zend 框架:

I have installed Laravel 4 after using 3, love it. I used to be able to use the Zend framework as such:

       $yt = new Zend_Gdata_YouTube();

例如

我已经使用composer安装了Zend,一切都安装在Vendor文件夹中..

I have used composer to install Zend and everything is installed in the Vendor folder..

问题:

如何处理各个类,例如 Zend Gdata 等.

How to address the individual classes i.e. Zend Gdata etc.

我在 L4 中找不到任何有关从供应商处调用类的文档.任何帮助表示赞赏.

I can't find any documentation on calling classes from a vendor in L4. Any help is appreciated.

推荐答案

看看你的 vendorcomposerautoload_classmap.php 文件.在那里,您将找到正在自动加载的所有供应商类的列表.我认为所有类都必须使用它们的完整命名空间名称来调用.

Take a look at your vendorcomposerautoload_classmap.php file. In there you will find a list of all vendor classes that are being autoloaded. I think all classes will have to be called using their full namespaced name.

例如

我正在使用 Zizaco 的 Entrust 包.这就是 vendorcomposerautoload_classmap.php 文件中的样子.

I'm using Zizaco's Entrust package. This is what it looks like in the vendorcomposerautoload_classmap.php file.

'Zizaco\Entrust\Entrust' => $vendorDir . /zizaco/entrust/src/Zizaco/Entrust/Entrust.php',

如果我想访问 Entrust.php 类,我必须调用

If I wanted to access the Entrust.php class I have to call

$en = new ZizacoEntrustEntrust();

或者,您可以在 appconfigapp.php 文件中为某些类设置别名.

Alternatively you could alias certain classes in your appconfigapp.php file.

例如

'Ent'         => 'ZizacoEntrustEntrust'

在您的情况下,您需要执行以下操作:

In your case you'll need to do something like this:

$yt = new Zend
amespaceend_Gdata_YouTube();

这篇关于Laravel 4 使用供应商类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆