Closed jcparejo closed 1 year ago
Hi, we don't currently support using this library without composer. To do so, you simply need to download the files from this repo (Code -> Download ZIP -> extract that, or git clone
the repository), and copy them into a vendor
directory in your PHP project. Then you just need to require_once('vendor/deepl-php/src/Translator.php');
all the files in src
and you're good to go. I'm working on an init.php
which makes it easier to use the library without composer, but I still need to test it better.
Also see this related StackOverflow question for how to deal with dependencies etc.
Thank you
I did it but it does work. I see a .composer on my host and i have include the vendor /deepl-php with all files It show a 500 error do i have to change any file ? i am new on it and i am a bit lost
How did you install the dependencies of the project and when do you get which error exactly?
I hace use FTP to upload in .composer/vendor/dewpl-php
Like I said, you will need to install the dependencies as well (and their dependencies), which is what composer would do for you. Check the stackoverflow link. The 500 error you get when you visit the website is just what your webserver serves to an end user, you would need to check your server's logs to get a stacktrace and see which error occurs server-side.
I have install deepl with compoer -> composer require deeplcom/deepl-php
later i have created a php file with
$authKey = " My deelp key"; // Replace with your key $translator = new \DeepL\Translator($authKey);
$result = $translator->translateText('Hello, world!', null, 'fr'); echo $result->text; // Bonjour, le monde!
But it does work
later, i have create a folder deepl2 in root createing the composer project and works.
i don know if i have to include any line more
Hi, sorry, could you clearly state
composer require deeplcom/deepl-php
, create script.php
in a folder with this structure:├── yourproject
│ ├── vendor
│ │ ├── deepl-php/...
│ ├── script.php
with the contents above, then run php script.php
)
Otherwise I have to guess. Make sure you changed the value in the line $authKey = " My deelp key"; // Replace with your key
to your DeepL API key.
Also, if you run it like I described above you need to load the library, the easiest way is to use the autoloader provided by composer, see the docs.
If you set up your project like I outlined above, it would simply be the following (again, with your API key)
require __DIR__ . '/vendor/autoload.php';
$authKey = " My deelp key"; // Replace with your key
$translator = new \DeepL\Translator($authKey);
$result = $translator->translateText('Hello, world!', null, 'fr');
echo $result->text; // Bonjour, le monde!
Hi JanEbbing
I have resolved it just adding the require link to the fólder whete IS the vendor files
Thank you for your time
Hi. I have problem with composer and deepl libraries.
It is posible to install without composer ?
Where are the files and a simple example in php for translate deepl using a frre api
best regards