PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 6, 2022

[FIXED] trying to import a file

 January 06, 2022     composer-php, php     No comments   

Issue

I'm a beginner in php, I'm trying to use a library but I'm facing an error

Fatal error: Uncaught Error: Class 'Einenlum\LingueeApi\Factory' not found in C:\xampp\htdocs\index.php:4 Stack trace: #0 {main} thrown in C:\xampp\htdocs\index.php on line 4

the library is this

I followed correctly what it says in the readme file my code is like this:

<?php
use Einenlum\LingueeApi\Factory;

$linguee = Factory::create();

$response = $linguee->translate('desert', 'eng', 'ger');

echo $response->toJson();
?>

I'm not sure if this readme file is giving me correct information, how can I run this project? enter image description hereenter image descriptiodddddn here


Solution

Since that library/package is managed via composer you'd need to use composer's autoload:

<?php
require __DIR__ . '/vendor/autoload.php';

use Einenlum\LingueeApi\Factory;
...

Find more information at https://getcomposer.org/doc/01-basic-usage.md#autoloading



Answered By - brombeer
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing