App Framework: How to use composer?

Hello!

I want to use composer in the app framework.
This is my composer.json:

{
  "name": "myApp",
  "require": {
    "firebase/php-jwt": "5.0.0"
  }
}

This file creates the vendor directory with the firebase dependendy.

When i want to use the library like this

use Firebase\JWT\JWT;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Controller;

class PageController extends Controller
{
    protected $appName;

    public function __construct($AppName, IRequest $request)
    {
        parent::__construct($AppName, $request);
        $this->appName = $AppName;
    }

    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     */
    public function index()
    {
        $jwt = $this->generateToken();
        $params = [
            'jwt' => $jwt
        ];
        $response = new TemplateResponse($this->appName, 'main', $params);
        return $response;
    }

    private function generateToken()
    {
        $key = "example_key";
        $token = array(
            "iss" => "http://example.org",
            "aud" => "http://example.com",
            "iat" => 1356999524,
            "nbf" => 1357000000
        );
        $jwt = JWT::encode($token, $key);
        return $jwt;
    }

}

I get the following message:
“Exception”:“Error”,“Message”:“Class ‘Firebase\\JWT\\JWT’ not found”

What do i have to do to correctly user composer the the app framework?

Regards

Fabian

Did you run composer install in app’s directory? You can also check usage of one of the owncloud’s own app as an example.

Yes, i did run composer install.
Then i copy the complete project to the owncloud/apps directory on my owncloud server (ubuntu).

I already checked some apps on github. It was a little bit confusing, some used a folder calles 3rdparty and some didn’t. Does this make a difference?