Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ErsinJuise's avatar

How do I integrate a php library not written for Laravel into Laravel?

How do I integrate a php library not written for Laravel into Laravel?

The api I want to use -> https://github.com/Hasokeyk/instagram/blob/main/README-TR.md

0 likes
14 replies
Sinnbeck's avatar

I dont speak the language, but install it using composer and follow the guide?

Sinnbeck's avatar

@ErsinJuise Exactly. Same as laravels framework. So in a controller for instance. You add this to the top

use Hasokeyk\Instagram\Instagram;

and the method

public function foo()
{
    $username = 'username';
    $password = 'password';

    $instagram = new Instagram($username,$password);
    $login = $instagram->login->login();
    if($login){
        return 'Login success';
    }else{
        return 'Login Fail';
    }
}
ErsinJuise's avatar

@Sinnbeck I installed it without any problems, yes, but I get the error "hasokeyk/instagram/instagram class not found". But when I look there is an existing folder there.

Sinnbeck's avatar

@ErsinJuise And you ran the require command from the root of your laravel project?

Can you show your controller file?

ErsinJuise's avatar

@Sinnbec

namespace App\Http\Controllers; use App; use Hasokeyk\Instagram\Instagram;

class indexController extends Controller { public function instagram(){ return view('front.instagram'); } }

martinbean's avatar

@ersinjuise Then read the README you’ve linked to. It has installation instructions, and then examples of usage.

ErsinJuise's avatar

@martinbean I have read the instructions but I am getting an error because the files have been moved in laravel.

martinbean's avatar

@ersinjuise What do you mean, moved? It’s a package. You install it with Composer, you then use it as per the README.

Laravel is just PHP. There’s nothing “Laravel specific” about using that package.

Please or to participate in this conversation.