Search code examples
phpapipathrootvimeo

What is the Path to root folder? Vimeo API


enter image description here

Im trying to run this Vimeo API in my PHP, and these are the error messages:

Warning: require(D:\XAMPP\htdocs\MyVimeo/autoload.php): failed to open stream: No such file or directory in D:\XAMPP\htdocs\MyVimeo\testing.php on line 9

Fatal error: require(): Failed opening required 'D:\XAMPP\htdocs\MyVimeo/autoload.php' (include_path='D:\XAMPP\php\PEAR') in D:\XAMPP\htdocs\MyVimeo\testing.php on line 9

And my question is, what is the path to the root folder? This is my source code that I'm trying to run:

<?php
      require 'D:\XAMPP\htdocs\MyVimeo/autoload.php';
      use Vimeo\Vimeo;
      $client = new Vimeo("xxx","xxx","xxx");

      $url="https://api.vimeo.com/videos/xxx";
      $ch=curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_URL, $url);
      echo curl_exec($ch);
      curl_close($ch);

Solution

  • You just need to put require 'vendor/autoload.php'; and not change to actual path.

    What you are missing is running composer install command in your root directory from the terminal

    According to the documentation

    With Composer, in the root directory of your project.

    composer require vimeo/vimeo-api
    

    Please note that this library requires at least PHP 7.1 installed. If you are on PHP 5.6, or PHP 7.0, please use install the package with the following:

    composer require vimeo/vimeo-api ^2.0
    

    Then once you do that, you can use

    require "vendor/autoload.php";