Laravel 4使用供应商类 [英] Laravel 4 using vendor classes
问题描述
我已经安装Laravel 4后使用3,爱它。
我以前可以使用Zend框架:
$ yt = new Zend_Gdata_YouTube
例如
安装Zend并且一切都安装在供应商文件夹中。
问题:
类,例如Zend Gdata等。
我找不到任何关于从L4供应商调用类的文档。
任何帮助。赞赏。
查看您的vendor\composer\autoload_classmap.php文件。在这里,您将找到正在自动加载的所有供应商类的列表。我认为所有的类都必须使用他们完整的命名空间名称来调用。
例如
我使用Zizaco的Entrust包。这是vendor \composer\autoload_classmap.php文件中的样子。
'Zizaco \\Entrust \\Entrust'=> $ vendorDir。 /zizaco/entrust/src/Zizaco/Entrust/Entrust.php',
如果我想访问Entrust.php类我必须调用
$ en = new Zizaco \Entrust\Entrust();
或者,您可以在app\config\app.php文件中对某些类进行别名。 p>
例如
'Ent'=> 'Zizaco \Entrust\Entrust'
在你的情况下,你需要这样做:
$ yt = new Zend\\\
amespace\Zend_Gdata_YouTube
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();
for instance
I have used composer to install Zend and everything is installed in the Vendor folder..
Problem:
How to address the individual classes i.e. Zend Gdata etc.
I can't find any documentation on calling classes from a vendor in L4. Any help is appreciated.
Take a look at your vendor\composer\autoload_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.
E.g.
I'm using Zizaco's Entrust package. This is what it looks like in the vendor\composer\autoload_classmap.php file.
'Zizaco\\Entrust\\Entrust' => $vendorDir . /zizaco/entrust/src/Zizaco/Entrust/Entrust.php',
If I wanted to access the Entrust.php class I have to call
$en = new Zizaco\Entrust\Entrust();
Alternatively you could alias certain classes in your app\config\app.php file.
E.g.
'Ent' => 'Zizaco\Entrust\Entrust'
In your case you'll need to do something like this:
$yt = new Zend\namespace\Zend_Gdata_YouTube();
这篇关于Laravel 4使用供应商类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!