using neoxygen php neoclient without dependencies

242 Views Asked by At

How can we use neoclient without any framework .Because we are not using laravel or symphony even we are using nothing like these frameworks.Our backend is written pure core PHP. Simply my question is that if we are not using any framework for core purposes then why should we use them to just use a dbms .

When i calculated the size of vendor folder it was of 102 MB. So a single request will use up a large part of ram. Its my guess that while using Neo-client the all files contained in vendor folder will be loaded. so please correct me and if neoclient can be used separately I will be very happy to use that, but please must tell what will be the cons of using Neo-Client without dependencies.

2

There are 2 best solutions below

0
On BEST ANSWER

I'm the creator and maintainer of NeoClient.

To answer simply your questions about dependencies :

  1. It uses some Symfony dependencies to have a really flexible configuration management, offering possibilities to work in clusters without proxies, also the possibility to have built-in extensions.

  2. It doesn't mean it is tight to any framework.

  3. In development mode, the boostrapping of the client is not optimized for sure, there is in the README a detail of how you can optimize the client with a single flag during the setup. The performances are really really good, here the result of the benchmark :

Benchmarking client instantation without cache, with result formatter enabled, 1000 runs Runned in 47.425533056259 seconds, using 8.5 mb memory

Benchmarking client instatation with cache enabled, 1000 runs Runned in 0.068459987640381 seconds, using 8.5 mb memory

NeoClient is used currently in more than 20 startups and enterprises which I'm aware of, and is now backed by GraphAware (the company I work for) for enterprise support.

Also, I created a Bolt driver (binary protocol in neo4j 3.0) https://github.com/graphaware/neo4j-bolt-php which will be implemented in NeoClient (this will require a bit of work because multi-protocol was not something I thought when I created it)

On the other side, the amount of dependencies does not mean it will instantiate all objects of all dependencies, Guzzle is used for its PSR-7 support and Curl abstraction, YAML is used if you provide config with YAML and all services are in lazy mode, meaning that all commands used internally will be really loaded into memory when called.

6
On

NeoClient

NeoClient is using only parts of Symfony framework. Listing:

"require": {
      "php": ">= 5.5",
      "guzzlehttp/guzzle": "^6.0",
      "monolog/monolog": "~1.1",
      "symfony/yaml": "^2.7",
      "symfony/config": "^2.7",
      "symfony/dependency-injection": "^2.7",
      "symfony/event-dispatcher": "^2.7",
      "graphaware/neo4j-response-formatter": "^1.0"
},

Moreover - autoloader (usually, provided by composer) is used to load files. This will load only files that are actually used (included/required) in runtime. So, you will not end up with 100MB PHP code in memory.

You run tests (with help of memory_get_usage and memory_get_peak_usage) to check how much memory is consumed by your application with/without NeoClient.

Alternatives

You can check out this section to find alternative drivers for php.

neo4jphp - looks promising. There are zero dependencies:

"require": {
  "php": ">=5.3.0",
  "ext-curl": "*"
},

So, this library is quite lightweight.


Note: Neo4j server is just REST API with JSON output. You can always implement simple library for your needs in project. But it's not recommended, because there are already lightweight alternatives existing.