Using a third party library without composer |
I would like to use this library in a controller but without installing it with composer. How do i go about that?
https://github.com/MaestroError/php-heic-to-jpg Where do I put the library and how do I properly namespace it? Does this look correct? require APPPATH . 'ThirdParty/HeicToJpg/src/HeicToJpg.php'; use Maestroerror\HeicToJpg;
1) Place the Library in app\ThirdParty
2) Open app\Config\Autoload.php 3) Add the Library to the $classmap 4) 'LibraryName' => APPPATH . 'ThirdParty/Libraryname.php', 5) Top of Controller - Use Libraryname 6) PHP Code: $library = new myLibrary(); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Okay awesome thank you!
I tried the above, do I need to include anything at the top of my Controller like the use keyword? If I implement the class like this: // autoload.php PHP Code: public $classmap = [ // Controller in a method PHP Code: $fileIsHeic = HeicToJpg::isHeic($_FILES['image-input']['tmp_name']); I get the error: Error: Class "App\Controllers\HeicToJpg" not found
Yes,
You need to add the class with the 'use' keyword. Try adding: PHP Code: use LibraryName |
Welcome Guest, Not a member yet? Register Sign In |