0

i am using dirkgroenen library php for authorization of my app and create board which i downloaded from here https://github.com/dirkgroenen/Pinterest-API-PHP evry time i run this code it gives me uncaught error about the line:8 Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in C:\xampp\htdocs\pin\vendor\demo\boot.php:8 here is the code for boot.php

 <?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    require ("../autoload.php");

    $dotenv = new Dotenv\Dotenv(__DIR__);
    $dotenv->load();

    $pinterest = new 
    DirkGroenen\Pinterest\Pinterest(getenv("4915445646307112766"), 
    getenv("1ae8683b277958bd9739cedb0f0b1434eee42176dd3d44cbf44981f9acaadd94"));

      if (isset($_GET["code"])) 
        {
          $token = $pinterest->auth->getOAuthToken($_GET["code"]);
          $pinterest->auth->setOAuthToken($token->access_token);

          setcookie("access_token", $token->access_token);
        }
      else if (isset($_GET["access_token"]))
        {
         $pinterest->auth->setOAuthToken($_GET["access_token"]);

        } 
      else if (isset($_COOKIE["access_token"])) 
        {
         $pinterest->auth->setOAuthToken($_COOKIE["access_token"]);
        } 
      else 
       {
         assert(false);
       }

     ?>

can anyone please help me to fix it.. i have spent more than 48 hours to resolve this issue.. any help will be greatly appreciated

Muhammad Hassan
  • 61
  • 1
  • 1
  • 7

1 Answers1

0

Obviously, you don't have Dotenv class anywhere where PHP expects it to be found.

Options:

  1. You don't have it at all, then download it from here: vlucas/phpdotenv. Composer should have downloaded it, BUT only if you used composer to install DirkGroenen.
  2. You have it but it is outside autoload path - check autoload path, make sure that Dotenv is located in appropriate vendor-folder.
  3. You have it but it doesn't support autoload (sic!) - check with latest version OR include it directly with include/require

It requires phpunit/phpunit to be installed aswell.

iXCray
  • 1,072
  • 8
  • 13