简体   繁体   English

使用neoxygen php neoclient没有依赖项

[英]using neoxygen php neoclient without dependencies

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. 如何。因为我们没有使用,我们可以使用neoclient没有任何框架laravelsymphony甚至我们使用什么比这些frameworks.Our后端写入纯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 . 我的简单问题是,如果我们不使用任何框架来实现核心目的,那么为什么我们应该使用它们仅使用dbms。

When i calculated the size of vendor folder it was of 102 MB . 当我计算供应商文件夹的大小时,它的大小为102 MB So a single request will use up a large part of ram. 因此,单个请求将占用ram的很大一部分。 Its my guess that while using Neo-client the all files contained in vendor folder will be loaded. 我的猜测是,在使用Neo-client时,将加载供应商文件夹中包含的所有文件。 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. 所以请纠正我,如果neoclient可以单独使用,我将非常乐意使用它,但是请务必说明使用没有依赖项的Neo-Client的弊端。

I'm the creator and maintainer of NeoClient. 我是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. 它使用一些Symfony依赖项来具有真正灵活的配置管理,从而提供了在没有代理的情况下在集群中工作的可能性,以及具有内置扩展的可能性。

  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 在不启用缓存的情况下对客户端实例化进行基准测试,并启用结果格式化程序,使用8.5 mb的内存在47.425533056259秒内运行1000次

Benchmarking client instatation with cache enabled, 1000 runs Runned in 0.068459987640381 seconds, using 8.5 mb memory 在启用缓存的情况下对客户端实例进行基准测试,运行1000次,使用8.5 mb内存,运行时间为0.068459987640381秒

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. 据我所知,NeoClient目前已在20多家初创企业和企业中使用,现在得到GraphAware(我工作的公司)的支持以提供企业支持。

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) 另外,我创建了一个Bolt驱动程序(neo4j 3.0中的二进制协议) https://github.com/graphaware/neo4j-bolt-php ,该驱动程序将在NeoClient中实现(这需要做一些工作,因为多协议不是什么我以为是我创建的)

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. 另一方面,依赖关系的数量并不意味着它将实例化所有依赖关系的所有对象,Guzzle用于其PSR-7支持和Curl抽象,如果您为config提供YAML并且所有服务都处于惰性模式,则使用YAML ,这意味着内部使用的所有命令在调用时都会真正加载到内存中。

NeoClient NeoClient

NeoClient is using only parts of Symfony framework. NeoClient仅使用Symfony框架的一部分。 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. 因此,最终不会在内存中包含100MB的PHP代码。

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. 您运行测试(与帮助memory_get_usagememory_get_peak_usage )检查多少内存用/你的应用程序而不NeoClient消耗。

Alternatives 备择方案

You can check out this section to find alternative drivers for php. 您可以查看节以找到php的替代驱动程序。

neo4jphp - looks promising. neo4jphp-看起来很有希望。 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. 注意: Neo4j服务器只是具有JSON输出的REST API。 You can always implement simple library for your needs in project. 您始终可以根据项目需求实现简单的库。 But it's not recommended, because there are already lightweight alternatives existing. 但是不建议这样做,因为已经存在轻量级的替代方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM