How to add GraphAware Library to project - php

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!

Related

Using "PHP Cache" without Composer

I found a PHP caching library that I'd like to use in CodeIgniter, but the docs only have instructions for installing / using with composer: http://www.php-cache.com/en/latest/
I inherited a project on a server that doesn't have Composer. Ideally I would like to use it without Composer. Does anyone have any knowledge of how to load this without it?
well, you could download the package itself and add it to your Codeignitter libraries autoload (if that's possible, sorry, dont know too much of CodeIgnitter). Though if i'd be you i'd go into Composer, it is revolutionary for php apps and you're loosing out so much by not using it... just composer init in main app folder & make sure that your CI is reading the autoloaded classes (i bet you'll find some tutorial for that)
by download I mean download and require in your php files where you're using it!

How to use Plivo PHP helper libraries without composer

I'm trying to use the Plivo PHP helper library in my project, but looks like the only way to use it is with Composer. Is there any work around for this since I cannot use composer in my project as it would change the existing code?
Plivo Sales Engineer here.
Unfortunately, Plivo-PHP helper library can be used only with Composer. If installing the library with Composer is not feasible, you could download and install the dependencies individually and include the libraries in your project. Or, you could also make HTTP requests to the API directly without using the helper library. You could use cURL or Requests library to make these requests.
I had a similar issue.
The access to the server was very limited, I had only FTP access, I could have waited to ask for SSH access to do the install using composer I simply installed Composer on my local machine and then just had to run
composer require plivo/php-sdk
In an empty directory. It created the SDK files under /vendor and I uploaded those files through FTP to the server. Did the job for me.

Beginner trouble understanding composer and frameworks

im having a really big problem understanding the usage of composer and frameworks.
The tutorials i have seen use some kind of online-editor so they dont really help me.
I learned about OOP etc and now i want to do the next step and learn about frameworks and composer.
I have a server and already managed to install composer. Plus i managed to install packages.
But what now? Can you tell me at a very basic level how to make use of this stuff?
I have an editor on my notebook and installed composer on my server. How do I interact with the classes?
Do i just write them and upload the file to check if it works? Do i somehow install them on my local environment? And if yes, how would i deploy my project afterwards?
I know its much but im not getting the basics of usage here :(
Thank you very much!
I watched tutorial for hours now but they always just seem to use the stuff. And i dont know how.
What you have to understand is that Composer is only a package manager, it will allow you to download some libraries (and their dependencies), and provide you an autoloader file to include on your files, so that you can use library classes.
Actually, you better install Composer on your local machine, develop your website locally, then, when it's ready, deploy it to your server.
A simple example, supposing you want to use Silex microframework.
Install Silex with composer
composer require 'silex/silex:1.3.0'
Include Silex in your script
Including Composer autoloader file
<?php
require_once './vendor/autoload.php';
$app = new Silex\Application();
?>
Develop
It's up to you, test it locally with a webserver installed on your computer.
Deploy
Deploy your website by pushing it on your webserver (with a FTP client for example).

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.

Trouble installing Omnipay via Netbeans composer extension

I am currently trying to install Omnipay into my Codeigniter project. I am stuck on windows because I do not have ssh access to the box where this needs to run on. So far I have gotten a new directory in the project root that is named "vendor" and it contains a lot of empty directories referring to Symfony (for what reason is beyond me).
Then I get a runtime exception that I need to enable the openssl extension in my php to download the necessary files and this is where I am stuck at. I don't run WAMP on my computer and I just use the php.exe I downloaded to work with netbeans.
Isn't there an easier way to get omnipay to run? Like just download the files from somewhere and plug them into my project like normal? It seems to be an aweful lot of headache to get a simple library to run in my CI project.
Please forgive my ignorance towards composer but I currently see no benefit of using it for this particular project.
You can "just download" the files here: https://github.com/omnipay/common/archive/master.zip
The problem is, Omnipay depends on Guzzle (an HTTP library), and Guzzle depends on some Symfony components. So you will spend the rest of the day downloading dependencies and making sure you have all the necessary files. That is the problem Composer solves for you.
I don't have any experience running Composer on Windows, but I would start here:
http://getcomposer.org/doc/00-intro.md#installation-windows
Using the Installer
This is the easiest way to get Composer set up on your machine.
Download and run Composer-Setup.exe, it will install the latest
Composer version and set up your PATH so that you can just call
composer from any directory in your command line.
Once you have Composer installed, you should simply be able to make a file named composer.json in your project root, with the following contents:
{
"require": {
"omnipay/omnipay": "~2.0"
}
}
Then use the Command Prompt and cd to your project's directory, and run composer update to download the Omnipay files and all their dependencies.

Categories