How to Load external library in Laravel-4?

How to Load external library in Laravel-4?

I was really confused that how to load library in laravel 4 and after search a lot on sites i got a nice and easy way to use external class inside a library.
Here are some steps that how to do it easily:-


1) First create a folder inside app

it should be like this

 app/libraries/your app folder/twitter.php
  twitter.php must contain a class and function.

 2) Open composer.json from your root folder
"autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/libraries"           
        ]
    },
 add this line "app/libraries"   as shown above

3)  Now open your CMD as administrator
Run command like:
composer dump-autoload
example: C:/wamp/www/sitename/>composer dump-autoload

4) now Open controller where you want to add that library

public function testfunction()
    {
        $Twitterapp = new twitterclass;
        $data['title'] .= $Twitterapp->get_user_details($sname);
        return View::make('viewpage')->with('data', $data);
      
    }



Comments