neo4j-php / neo4j-symfony Goto Github PK
View Code? Open in Web Editor NEWSymfony Bundle for the Neo4j Graph Database
License: MIT License
Symfony Bundle for the Neo4j Graph Database
License: MIT License
Hello,
A have received deprecation message The "neo4j.entity_manager" service is private, checking for its existence is deprecated since Symfony 3.2 and will fail in 4.0.
. As I understood when sets alias for default manager it sets with private true but default service creates as not private.
Message fires from Neo4jBundle::boot()
. Here it is private.
Maybe I doing something wrong.
I have changed $container->setAlias('neo4j.entity_manager', 'neo4j.entity_manager.default'
)` to
$id = new Alias($container->normalizeId('neo4j.entity_manager.default'), true);
$container->setAlias('neo4j.entity_manager', $id);
that help to set Alias as not private. But debug still tell that service is private..
php bin/console debug:container neo4j.entity_manager
// This service is an alias for the service neo4j.entity_manager.default
Information for Service "neo4j.entity_manager.default"
======================================================
---------------- ------------------------------------
Option Value
---------------- ------------------------------------
Service ID neo4j.entity_manager.default
Class GraphAware\Neo4j\OGM\EntityManager
Tags -
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
---------------- ------------------------------------
Maybe I'm doing something wrong? I just add it and all tests fired deprecations
This is a typo in the config.
I just released 0.4.2. There is not much activity in this repo but we got quite a few downloads and everything seams stable.
I suggest we tag 1.0.0 and start with "real" version numbers.
Hello,
I have encountered a strange bug regarding the configuration of the port in the neo4j.yml file on an application in Symfony 4.3.
If the port is 'hard' configured - aka 7687 -, all is ok. But if we refer instead to an environment variable with the syntax '%env(NEO4J_PORT)%', everything crumbles and the connection crashes with this following error message:
In StreamSocket.php line 203:
Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known
The crazy thing is that the port is the only configuration leading to that bug, using environment variables to configure the host or the user is ok.
Digging into the bundle, I finally found the origin of the problem: the port is cast into an integer in the depency injection: https://github.com/neo4j-contrib/neo4j-symfony/blob/master/DependencyInjection/Neo4jExtension.php#L206
That cast is ok if the port is 'hard' configured, but if someone want to use an environment variable it's no longer working because Symfony does not inject at this step the values of the variable but a proxy which will be solved later, in my example env_e68e500d790ef07c_NEO4J_PORT_2f05a784d88d91a07d4331d3f53a7cab
. Casting this string into an integer returns 0, causing a lot of troubles in cascade.
Is it possible to correct this point? The solution is to use the pattern '% s: //% s:% s @% s:% s'
instead of '% s: //% s:% s @% s:% d'
Thank you !
Currently, when you use neo4j-bundle you can only use annotation mapping because it's the EntityManager's default way to load mapping information. As XML mapping is basically possible, I think this bundle should support defining custom mapping information as well.
So I'd like to suggest this feature, which would enable to configure the mapping information via the configuration file, just like Doctrine does it. In doctrine-bundle you can specify the mappings to be used by an entity manager, by specifying them in the configuration like this:
doctrine:
orm:
entity_managers:
default:
[...]
mappings:
mapping_name:
mapping: true
type: ~
dir: ~
alias: ~
prefix: ~
is_bundle: ~
My suggestion is to implement the same structure to neo4j-bundle. Omitting the mappings configuration should lead to using annotations, just like before, in order to keep BC.
Notice: @ikwattro mentioned, XML mapping might need some updating on graphaware/neo4j-php-ogm's side.
As a test, I've recently created a graphenedb instance in the cloud.
I've filled in the remote connection strings in the config.yml and then I get an "Error receiving data", with no clue what part of the connection is not established.
The scheme, host and port are correct because if I change them, they give a different error.
Changing the user or password results in error. Reading the graphene PHP guide, it appears to need a TLS required setting. How do I check if this is set? And how do I determine what part of the connection string causes the error?
Will there be up-to-date package versions (like PHP 8) in composer.json any time soon? I tried to install it with my pre-existing Laravel installation, but it turns out to be impossible even with downgrading other packages, which in itself is already annoying.
To fix this update the Controller class : src/AppBundle/Controller/MovieController.php line 31
into
$title = str_replace('/',' ', $movieNode->get('title'));
$movie['url']` = $this->generateUrl('movies_show', ['title' => $title]);
Hi @Nyholm ,
Is it advisable to you that we change the config for the port setting from integerNode to scalarNode ?
https://github.com/neo4j-contrib/neo4j-symfony/blob/master/DependencyInjection/Configuration.php#L90
The use case is when the port is passed via the env and sf 3.3 does not support casting of string values.
ServiceNotFoundException
The "neo4j.client" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
My composer.json is it:
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"friendsofsymfony/rest-bundle": "^2.3",
"graphaware/neo4j-common": "^3.5",
"graphaware/neo4j-php-ogm": "^1.0@RC",
"jms/serializer-bundle": "^2.4",
"neo4j/neo4j-bundle": "^0.4.1",
"sensio/framework-extra-bundle": "^5.1",
"symfony/console": "^4.1",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.1",
"symfony/lts": "^4@dev",
"symfony/yaml": "^4.1"
},
"require-dev": {
"symfony/dotenv": "^4.1"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false
}
}
}
And my code is it:
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use FOS\RestBundle\Controller\Annotations as FOSRest;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* @Route("/api/v1")
*/
class DemoController extends Controller
{
/**
* Test
* @FOSRest\Get("/test")
* @return array
*/
public function test()
{
$client = $this->getNeo4jClient();
$results = $client->run('MATCH (n:Movie) RETURN n LIMIT 5');
$element = array();
foreach ($results->records() as $record) {
$node = $record->get('n');
$element[] = $node->get('title'); // "The Matrix"
}
$iResponse = new JsonResponse();
$iResponse->setData(array('demo' => true, 'elements' => $element));
return $iResponse;
}
/**
* @return \GraphAware\Neo4j\Client\Client
*/
private function getNeo4jClient()
{
return $this->get('neo4j.client');
}
}
Update : vendor/neo4j/neo4j-bundle/Collector/QueryLogger.php
private function statisticsToArray(StatementStatisticsInterface $statementStatistics = null)
{
if (is_null($statementStatistics)) return [];
$data = [
'contains_updates' => $statementStatistics->containsUpdates(),
'nodes_created' => $statementStatistics->nodesCreated(),
'nodes_deleted' => $statementStatistics->nodesDeleted(),
'relationships_created' => $statementStatistics->relationshipsCreated(),
'relationships_deleted' => $statementStatistics->relationshipsDeleted(),
'properties_set' => $statementStatistics->propertiesSet(),
'labels_added' => $statementStatistics->labelsAdded(),
'labels_removed' => $statementStatistics->labelsRemoved(),
'indexes_added' => $statementStatistics->indexesAdded(),
'indexes_removed' => $statementStatistics->indexesRemoved(),
'constraints_added' => $statementStatistics->constraintsAdded(),
'constraints_removed' => $statementStatistics->constraintsRemoved(),
];
return $data;
}
Hi everyone,
We are trying tu use this bundle with a Neo4j cluster. We followed the neo4j instructions to create an HAProxy cluster, but i can't get hold of the proper configuration to put using this bundle.
neo4j.connection.default
neo4j.connection.second_connection
Can you give me more info about these fields. I need to declare a master (for write queries) and slaves, how can i do that ?
Thanks, in advance, for your help
EntityManagerInterface method createQuery is missed. EntityManager have it. Can be problems with some code checkers in this case.
Pls add recipe for your bundle here: https://github.com/symfony/recipes-contrib
So your flex will be able to copy your bundle's default config to config/packages
folder automatically
Is this still being maintained?
I get this warns when I install the package
Package graphaware/neo4j-bolt is abandoned, you should avoid using it. No replacement was suggested.
Package graphaware/neo4j-php-client is abandoned, you should avoid using it. No replacement was suggested.
¿It's correct?
Ok. I try make my explanation more detailed.
When load Extension (line 44) in Neo4jBundle and if ChildDefinition::class
exists EnitytManagers creates as ChildDefinition
. By default service will creates as public. And we can see that it public if we check it state before setting alias for it.
What I mean before this line $container->setAlias('neo4j.entity_manager', 'neo4j.entity_manager.default');
service is public (properties setted public = true, private = false).
After alias was set service have changed his properties to public = true, private = true.
But as I understood from answer on my previous issue EntityManager planed as private. Now I confused because here on Neo4jBundle::boot() call you have checking if container has neo4j.entity_manager and if you planed that it private why you use deprecated method for checking.
If we take a look how doctrine EntityManager registration realized than we can see that it creates as public and, as I understand, to avoid properties change on alias set they call setPublic(true).
And finally issue: Could you fix Neo4jBundle::boot() to avoid deprecation usage $this->container->has('neo4j.entity_manager')
for check.
Thank you
Hello,
I try to use neo4j with Symfony Guard, but I got an error about the unserialized security token:
Here the error log:
[2019-01-28 07:41:03] security.WARNING: Failed to unserialize the security token from the session. {"key":"_security_main","received":"C:67:\"Symfony\\Component\\Security\\Guard\\Token\\PostAuthenticationGuardToken\":3481:{a:2:{i:0;s:4:\"main\";i:1;s:3446:\"a:4:{i:0;O:31:\"neo4j_ogm_proxy_App_Entity_User\":23:{s:35:\"\u0000neo4j_ogm_proxy_App_Entity_User\u0000em\";N;s:44:\"\u0000neo4j_ogm_proxy_App_Entity_User\u0000initialized\";a:0:{}s:45:\"\u0000neo4j_ogm_proxy_App_Entity_User\u0000initializers\";a:0:{}s:37:\"\u0000neo4j_ogm_proxy_App_Entity_User\u0000node\";O:32:\"GraphAware\\Bolt\\Result\\Type\\Node\":3:{s:11:\"\u0000*\u0000identity\";i:31;s:9:\"\u0000*\u0000labels\";a:1:{i:0;s:4:\"User\";}s:13:\"\u0000*\u0000properties\";a:14:{s:17:\"membershipLevelId\";i:3;s:9:\"findCount\";i:0;s:9:\"avatarUrl\";s:88:\"https://example.com/test.jpg\";s:9:\"bannerUrl\";s:91:\"https://example.com/test.jpg\";s:6:\"userId\";i:1;s:5:\"token\";s:520:\"randomtoken\";s:9:\"createdAt\";i:1548630927;s:15:\"tokenExpiration\";i:1548664782;s:9:\"hideCount\";i:0;s:14:\"favoritePoints\";i:0;s:13:\"referenceCode\";s:7:\"1\";s:9:\"updatedAt\";i:1548661185;s:12:\"refreshToken\";s:64:\"randomtoken\";s:8:\"username\";s:6:\"username\";}}s:5:\"\u0000*\u0000id\";i:31;s:23:\"\u0000App\\Entity\\User\u0000userId\";i:1220432;s:30:\"\u0000App\\Entity\\User\u0000referenceCode\";s:7:\"1\";s:25:\"\u0000App\\Entity\\User\u0000username\";s:6:\"username\";s:34:\"\u0000App\\Entity\\User\u0000membershipLevelId\";i:3;s:26:\"\u0000App\\Entity\\User\u0000avatarUrl\";s:88:\"https://example.com/test.jpg\";s:26:\"\u0000App\\Entity\\User\u0000bannerUrl\";s:91:\"https://example.com/test.jpg\";s:32:\"\u0000App\\Entity\\User\u0000homeCoordinates\";N;s:26:\"\u0000App\\Entity\\User\u0000findCount\";i:0;s:26:\"\u0000App\\Entity\\User\u0000hideCount\";i:0;s:31:\"\u0000App\\Entity\\User\u0000favoritePoints\";i:0;s:22:\"\u0000App\\Entity\\User\u0000token\";s:520:\"randomtoken\";s:32:\"\u0000App\\Entity\\User\u0000tokenExpiration\";i:1548664861;s:26:\"\u0000App\\Entity\\User\u0000createdAt\";O:8:\"DateTime\":3:{s:4:\"date\";s:26:\"2019-01-27 23:15:27.000000\";s:13:\"timezone_type\";i:1;s:8:\"timezone\";s:6:\"+00:00\";}s:26:\"\u0000App\\Entity\\User\u0000updatedAt\";O:8:\"DateTime\":3:{s:4:\"date\";s:26:\"2019-01-28 07:41:03.650728\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:3:\"UTC\";}s:22:\"\u0000App\\Entity\\User\u0000roles\";a:0:{}s:24:\"\u0000App\\Entity\\User\u0000friends\";N;s:21:\"\u0000App\\Entity\\User\u0000logs\";N;}i:1;b:1;i:2;a:1:{i:0;O:41:\"Symfony\\Component\\Security\\Core\\Role\\Role\":1:{s:47:\"\u0000Symfony\\Component\\Security\\Core\\Role\\Role\u0000role\";s:9:\"ROLE_USER\";}}i:3;a:0:{}}\";}}","exception":"[object] (ErrorException(code: 57873340): Class not found: neo4j_ogm_proxy_App_Entity_User at /home/baptiste/git/FriendLeagueActivity/vendor/symfony/security-http/Firewall/ContextListener.php:264)"} []
[2019-01-28 07:41:03] security.DEBUG: Read existing security token from the session. {"key":"_security_main","token_class":null} []
[2019-01-28 07:41:03] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":1} []
[2019-01-28 07:41:03] security.DEBUG: Checking support on guard authenticator. {"firewall_key":"main","authenticator":"App\\Surfoo\\GeocachingBundle\\Security\\GeocachingAuthenticator"} []
[2019-01-28 07:41:03] security.DEBUG: Guard authenticator does not support the request. {"firewall_key":"main","authenticator":"App\\Surfoo\\GeocachingBundle\\Security\\GeocachingAuthenticator"} []
[2019-01-28 07:41:03] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
The exception here:
"exception" => ErrorException {#274 ▼
#message: "Class not found: neo4j_ogm_proxy_App_Entity_User"
#code: 57873340
#file: "/home/user/git/project/vendor/symfony/security-http/Firewall/ContextListener.php"
#line: 264
#severity: E_ERROR
trace: {▼
/home/user/git/project/vendor/symfony/security-http/Firewall/ContextListener.php:264 {▶}
Symfony\Component\Security\Http\Firewall\ContextListener::handleUnserializeCallback() {}
/home/user/git/project/vendor/symfony/security-core/Authentication/Token/AbstractToken.php:154 {▶}
/home/user/git/project/vendor/symfony/security-guard/Token/PostAuthenticationGuardToken.php:88 {▶}
Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken->unserialize() {}
/home/user/git/project/vendor/symfony/security-http/Firewall/ContextListener.php:242 {▶}
/home/user/git/project/vendor/symfony/security-http/Firewall/ContextListener.php:95 {▶}
/home/user/git/project/vendor/symfony/security-bundle/Debug/WrappedListener.php:46 {▶}
/home/user/git/project/vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php:35 {▶}
/home/user/git/project/vendor/symfony/security-http/Firewall.php:90 {▶}
/home/user/git/project/vendor/symfony/security-bundle/EventListener/FirewallListener.php:48 {▶}
/home/user/git/project/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:111 {▶}
/home/user/git/project/vendor/symfony/event-dispatcher/EventDispatcher.php:212 {▶}
/home/user/git/project/vendor/symfony/event-dispatcher/EventDispatcher.php:44 {▶}
/home/user/git/project/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:145 {▶}
/home/user/git/project/vendor/symfony/http-kernel/HttpKernel.php:126 {▶}
/home/user/git/project/vendor/symfony/http-kernel/HttpKernel.php:67 {▶}
/home/user/git/project/vendor/symfony/http-kernel/Kernel.php:198 {▶}
/home/user/git/project/public/index.php:37 {▼
Is there an issue or a bad configuration on my side?
Would be nice to see in the profiler if the query was sent with http or bolt
Using the instructions in the readme it doesn't install.
Composer require neo4j/neo4j-bundle
"Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for neo4j/neo4j-bundle ^0.4.2 -> satisfiable by neo4j/neo4j-bundle[0.4.2].
- neo4j/neo4j-bundle 0.4.2 requires symfony/dependency-injection ^2.8.3 || ^3.0.3 || ^4.0 -> no matching package found."
Installed version of dependency-injection is 5.1.2
Getting following error when tried this on Symfony4
In Neo4jDataCollector.php line 90:
Error: Class Neo4j\Neo4jBundle\Collector\Neo4jDataCollector contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface::reset)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.