Download the PHP package kitlabs/neo4j-php-client without Composer

On this page you can find all versions of the php package kitlabs/neo4j-php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package neo4j-php-client

Neo4j PHP Client and Driver

GitHub Code Climate maintainability Packagist PHP Version Support (custom server) Latest Stable Version

Packagist Downloads Packagist Downloads

Control to worlds' most powerful graph database

See the driver in action

For some more detailed write-ups you can refer to these blogposts:

Or watch any of these videos.

Start your driving experience in three easy steps

Step 1: install via composer

Find more details here

Step 2: create a client

You have now created a client with bolt, HTTPS and neo4j drivers. The default driver that the client will use is bolt.

Read more about the URLs and how to use them to configure drivers here.

Step 3: run a transaction

Decide how to send your Cypher queries

You can control the driver using three different approaches:

Auto committed queries

Auto committed queries are the most straightforward and most intuitive but have many drawbacks when running complex business logic or within a high availability environment.

Run a simple cypher query

Run a statement object:

Running multiple queries at once

The runStatements method will run all the statements at once. This method is an essential tool to reduce the number of database calls, especially when using the HTTP protocol.

Transaction functions

Transaction functions are the de facto standard when using the driver. It is the most portable as it is resistant to a lot of the pitfalls when first developing with high availability solutions such as Neo4j aura or a cluster.

The driver manages transaction functions:

ATTENTION: Because of the automatic retry functionality, the function should produce the same result on subsequent recalls, or in more technical terms: should be idempotent. Always remember this when designing the execution logic within the function.

Some examples:

Unmanaged transactions

If you need lower-level access to the drivers' capabilities, then you want unmanaged transactions. They allow for completely controllable commits and rollbacks.

Opening a transaction

The beginTransaction method will start a transaction with the relevant driver.

Note that beginTransaction only returns the transaction object, not the results of the provided statements.

Running statements within a transaction

The transaction can run statements just like the client object as long as it is still open.

Finish a transaction

Rollback a transaction:

Commit a transaction:

Accessing the results

Results are returned in a standard format of rows and columns:

Cypher values and types map to these php types and classes:

Cypher Php
null * null
string * string
integer * int
float * float
boolean * bool
Map * \Laudis\Neo4j\Types\CypherMap
List * \Laudis\Neo4j\Types\CypherList
Point * \Laudis\Neo4j\Contracts\PointInterface **
Date * \Laudis\Neo4j\Types\Date
Time * \Laudis\Neo4j\Types\Time
LocalTime * \Laudis\Neo4j\Types\LocalTime
DateTime * \Laudis\Neo4j\Types\DateTime
DateTimeZoneId * \Laudis\Neo4j\Types\DateTimeZoneId
LocalDateTime * \Laudis\Neo4j\Types\LocalDateTime
Duration * \Laudis\Neo4j\Types\Duration
Node \Laudis\Neo4j\Types\Node
Relationship \Laudis\Neo4j\Types\Relationship
Path \Laudis\Neo4j\Types\Path

(*) These items can also be used as parameters in the bolt protocol and will automatically be converted by the driver, so they can be used in Cypher.

Besides these examples, \DateTimeInterface will map to DateTimeZoneId in Cypher. An empty or list-type array will be converted to a cypher List, and an associative array will be converted to a map.

(**) A point can be one of four types implementing PointInterface: \Laudis\Neo4j\Types\CartesianPoint \Laudis\Neo4j\Types\Cartesian3DPoint \Laudis\Neo4j\Types\WGS84Point \Laudis\Neo4j\Types\WGS843DPoint

Diving Deeper

Differentiating between parameter type

Cypher has lists and maps. This notion can be problematic as the standard php arrays encapsulate both. When you provide an empty array as a parameter, it will be impossible to determine an empty list or map.

The ParameterHelper class is the ideal companion for this:

Version compatibility matrix

Driver Version PHP Version Neo4j Version
^2.8 7.4, ^8.0 ^3.5, ^4.0
^3.0 ^8.0 ^4.0, ^5.0

Neo4j Feature Support

Feature Supported?
Authentication Yes
Transactions Yes
Http Protocol Yes
Bolt Protocol Yes
Cluster Yes
Aura Yes
Jolt Protocol Yes
Bookmarks Yes

In-depth requirements

(*) Needed to implement the bolt protocol

(**) Needed to implement the http protocol

(***) Can be installed for optimal bolt protocol performance

If you plan on using the HTTP drivers, make sure you have psr-7, psr-17 and psr-18 implementations included into the project. If you don't have any, you can install them via composer:

Result formats/hydration

In order to make the results of the bolt protocol and the http uniform, the driver provides result formatters (aka hydrators). The client is configurable with these formatters. You can even implement your own.

The default formatter is the \Laudis\Neo4j\Formatters\OGMFormatter, which is explained extensively in the result format section.

The driver provides three formatters by default, which are all found in the Formatter namespace:

The client builder provides an easy way to change the formatter:

In order to use a custom formatter, implement the Laudis\Neo4j\Contracts\FormatterInterface and provide it when using the client builder.

Concepts

The driver API described here is the main target of the driver. Because of this, the client is nothing more than a driver manager. The driver creates sessions. A session runs queries through a transaction.

Because of this behaviour, you can access each concept starting from the client like this:

If you need complete control, you can control each object with custom configuration objects.

Client

A client manages drivers and routes the queries to the correct drivers based on preconfigured aliases.

Driver

The driver object is the thread-safe backbone that gives access to Neo4j. It owns a connection pool and can spawn sessions for carrying out work.

Session

Sessions are lightweight containers for causally chained sequences of transactions. They borrow connections from the connection pool as required and chain transactions using bookmarks.

Transaction

Transactions are atomic units of work that may contain one or more query. Each transaction is bound to a single connection and is represented in the causal chain by a bookmark.

Statement

Queries are executable units within transactions and consist of a Cypher string and a keyed parameter set. Each query outputs a result that may contain zero or more records.

Result

A result contains the output from a query, made up of header metadata, content records and summary metadata. In Neo4j 4.0 and above, applications have control over the flow of result data.

In-depth configuration

Url Schemes

The URL scheme is the easiest way to configure the driver.

Configuration format:

Default configuration:

Scheme configuration matrix

This library supports three drivers: bolt, HTTP and neo4j. The scheme part of the url determines the driver.

driver scheme valid certificate self-signed certificate function
neo4j neo4j neo4j+s neo4j+ssc Client side routing over bolt
bolt bolt bolt+s bolt+ssc Single server over bolt
http http https configured through PSR Client implementation Single server over HTTP

Configuration objects

A driver, session and transaction can be configured using configuration objects. An overview of the configuration options can be found here:

name concept description class
user agent driver The user agent used to identify the client to the neo4j server. DriverConfiguration
Http PSR Bindings driver The relevant PSR implementation used by the driver when using the HTTP protocol. DriverConfiguration
database session The database to connect to. SessionConfiguration
fetch size session The amount of rows to fetch at once. SessionConfiguration
access mode session The default mode when accessing the server. SessionConfiguration
bookmarks session The bookmarks used in the session. (experimental) SessionConfiguration
metadata transaction The metadata used during the transaction. (experimental) TransactionConfiguration
timeout transaction The maximum amount of time before timing out. TransactionConfiguration

Code Example:


All versions of neo4j-php-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laudis/typed-enum Version ^1.3
php-http/discovery Version ^1.13
psr/http-message Version ^1.0|^2.0
psr/http-factory Version ^1.0
psr/http-client Version ^1.0
php-http/message Version ^1.0
stefanak-michal/bolt Version ^5.1
symfony/polyfill-php80 Version ^1.2
psr/simple-cache Version >=2.0
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kitlabs/neo4j-php-client contains the following files

Loading the files please wait ....