Laravel 4 using vendor classes

♀尐吖头ヾ 提交于 2019-11-30 15:37:20

问题


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.


回答1:


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();


来源:https://stackoverflow.com/questions/15398087/laravel-4-using-vendor-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!