Use a vendor class from composer in Laravel

2019-09-13 06:23发布

How would I go around using this class/library in Laravel: https://github.com/planetteamspeak/ts3phpframework

I tried to include it in config/app.php providers like this:

planetteamspeak\ts3-php-framework\libraries\TeamSpeak3.php::class,

But I keep getting this error, and I couldn't find anything about it that helped me. I also tried to add it without .php at the end but that doesn't help either.

Fatal error: Uncaught ReflectionException: Class log does not exist in PATH-HERE\vendor\laravel\framework\src\Illuminate\Container\Container.php:734

I'll appreciate any help, thanks!

1条回答
狗以群分
2楼-- · 2019-09-13 06:47

To use your class/library in Laravel, first you should put in your composer.json dependecy for that ts3phpframework

"require": {
"planetteamspeak/ts3phpframework" : "1.*"
}

Inside file app.php you need to do 2 things (something like this, dunno the proper name of alias and provider (be sure to do composer update before doing it)

First add provider (just a hint how to do it)

'providers' => [
ts3phpframework/ts3phpframeworkProvider::class
]

Second add alias (just a hint how to do it)

'aliases' => [
'ts3phpframework' => ts3phpframework\Facades\ts3phpframework::class,
]

If you won't be able to get this library with composer, then add it manually with a help of this. If you won't be able to find alias and provider, then create them manually with a help of this.

And at the end, very similar question already answered here

查看更多
登录 后发表回答