3805

Use a vendor class from composer in Laravel

Question:

How would I go around using this class/library in Laravel: <a href="https://github.com/planetteamspeak/ts3phpframework" rel="nofollow">https://github.com/planetteamspeak/ts3phpframework</a>

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!

Answer1:

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 <a href="http://blog.jambura.com/2014/04/26/add-your-own-github-library-in-laravel-using-composer/" rel="nofollow">help of this</a>. If you won't be able to find alias and provider, then create them manually with a help of <a href="https://stackoverflow.com/questions/16957790/how-do-i-create-a-facade-class-with-laravel/19811029#19811029" rel="nofollow">this</a>.

And at the end, very similar question already answered <a href="https://stackoverflow.com/a/38344851/5139222" rel="nofollow">here</a>

Recommend

  • MySQL first free number between exists values
  • Class 'TeamSpeak3_Helper_Uri' not found
  • How to append distinct records from one table to another
  • Copying files and creating new folders based on “creationdate”
  • Escape exclamation mark in batch file
  • Doctrine: UniqueEntity with Many-to-Many field
  • Catching exception and throwing the same?
  • include dlls in visual studio c++ 2008
  • react split panel resize
  • Can you pass an array from javascript to asp.net mvc controller action without using a form?
  • Error processing multiple files
  • how to upload multiple files in c# windows application
  • MS Access - How to change the linked table path by amend the table
  • JBoss External Properties Files in Classpath
  • Eloquent paginate function in Slim 3 project using twig
  • Connect .sks to skscene.h
  • Xcode 4 NSLog Macro link in Xcode 3
  • Why does access(2) check for real and not effective UID?
  • Checking free space on FTP server
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Upload files with Ajax and Jquery
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • File not found error Google Drive API
  • Qt: Run a script BEFORE make
  • Linking SubReports Without LinkChild/LinkMaster
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • UserPrincipal.Current returns apppool on IIS