Use Google Translate library without composer - php

I am trying to integrate Google Translate library in a legacy application which does not use composer, and I have downloaded the source code folder "google-cloud-php-master".
Can anyone point me how to use the library without composer?
When I try to execute the below code
use Google\Cloud\Translate\TranslateClient;
$translate = new TranslateClient();
I am getting the below error. Any help would be appreciate.
Fatal error: Class 'Google\Cloud\Translate\TranslateClient' not found

Related

How to use library in CI4?

I am working on a website with PHP 7.4.15 and CI 4.1.1.
I need to use phpspreadsheet library so I installed it by composer.
but when I try to use that class , the below error shows.
Class 'PhpOffice\\PhpSpreadsheet\\Spreadsheet' not found
According to CI4 documents, CI4 find Composer Auto Load files.
Do I need to set other things?
Any ideas can be helpful for me.

How to import properly 3rd party libraries into Laravel project?

My problem is, I don't know how to install properly scotch-panels in Laravel project. I installed scotch-panels by:
npm install scotch-panels
and compile it by:
npm run dev
but I have error in console, when I used function from scotch-panels library:
Uncaught TypeError: $(...).scotchPanel is not a function
I tried extract module to vendor.js (like documentation said), but node states:
Module not found: Error: Can't resolve 'scotch-panels' in [...]
Unfortunately, link manually library it's not a option. I add that jQuery of course works properly.
I tried with other modules but once it's working, once not. I really don't know, what happened here.
Any help is highly appreciated with this, because I'm confused now.

Yii2 composer installed library does not recognized by namespaces

I am trying to deploy a Yii2 app that consumes OData services. But I am having a bit problem: I choose https://github.com/saintsystems/odata-client-php (OData Client library from SaintSystems), I installed with composer and there was no complain. But when I use instantiate the objects it says:
$odataClient = new ODataClient($odataServiceUrl);
Then
Error
Class 'app\controllers\ODataClient' not found
And if
$odataClient = new \SaintSystems\OData\ODataClient($odataServiceUrl);
Then it complains with:
Call to undefined method SaintSystems\OData\Query\Builder::post()
So I think Yii 2 is not recognizing the namespaces or composer does not set them up correctly. How could I make yii2 take this namespace and I deploy successfully with this library.
Thank you all!

How to add GraphAware Library to project

I am creating a project in php and want to configure it with my Neo4j graph data. Here is the code:
<?php
require_once '/path/to/Client.php';
use GraphAware\Neo4j\Client;
use GraphAware\Neo4j\Client\ClientBuilder;
$client = new GraphAware\Neo4j\Client('http://127.0.0.1:7474/');
$client = ClientBuilder::create()
->addConnection('default', 'http://neo4j:password#127.0.0.1:7474')
->addConnection('bolt', 'bolt://neo4j:password#127.0.0.1:7474')
->build();
so you can see that the library I am trying to use in GraphAware. I cannot get this library to work as I do not have it. Can someone please let me know how I can get this library in my php project which I am creating in eclipse.
As per the documentation, you use Composer to require it into your project.
https://github.com/graphaware/neo4j-php-client#installation
composer require graphaware/neo4j-php-client:^4.0
Don't have composer? It's well worth installing, manages dependencies and autoloading, and all you need to do to get it working with any PHP project is to add this line pretty much at the start point of your script (index.php?)
require_once 'vendor/autoload.php`
Get Composer here https://getcomposer.org/
The lame non-composer way is just download the Zip from github and dump it in your project. But you'll need to require in all the classes you use!
If your creating a PHP project in eclipse you can download the composer in eclipse form here: https://marketplace.eclipse.org/content/composer-php-support
All you have to do is drag it into your running workspace. This will download all the libraries and dependencies for you. This is done by writing composer before the require statement.
The composer for eclipse is available in the following versions: Mars(4.5), Luna(4.4), Kepler(4.3). It is also supported by Windows, Mac and Linux/GTK
Before you download the composer the PHP development tools (PDT) are required.
Just to add. I have tried this in eclipse mars but it did not work for me so I tried it in Neo Oxygen and it worked!

Using composer installed library, class not found error

I used composer to download a php bitcoin library to play around with. https://github.com/phramz/php-bitcoin-api
This one specifically.
Anyways, everytime I try to use the library with
use Phramz\Bitcoin\Api\Connection\BuzzConnection;
use Phramz\Bitcoin\Api\BitcoindClient;
I get
Interface 'Phramz\Bitcoin\Api\Client' not found in
/root/vendor/phramz/php-bitcoin-api/src/Phramz/Bitcoin/Api/BitcoindClient.php
whenever I try to run any test code. I really want to play around with this library but Im sort of a newbie php programmer and this is frustrating me. Any help would be appreciated!
Make sure you require vendor/autoload.php as described in Composer documentation.
If Composer's vendor directory is not located in the current directory you'll need to use an absolute path or something like:
<?php
require_once(__DIR__."/../../vendor/autoload.php");
I had the kind of issue when I installed a new lib, and i just deployed the new lib to server only as I was new to PHP, it took me hours to figure out that the vendor/composer folder is updated when we install a new lib.
So if your server doesn't support composer install , upload the whole vendor folder to your server is the way.

Categories