Adding Social Network Features to a PHP App with Neo4j

Originally published at: http://www.sitepoint.com/adding-social-network-features-php-app-neo4j/

This entry is part 2 of 2 in the series Graph Databases in PHP with Neo4j

Graph Databases in PHP with Neo4j

In the last part, we learned about Neo4j and how to use it with PHP. In this post, we’ll be using that knowledge to build a real Silex-powered social network application with a graph database.

Bootstrapping the application

I’ll use Silex, Twig, Bootstrap and NeoClient to build the application.

Create a directory for the app. I named mine spsocial.

Add these lines to your composer.json and run composer install to install the dependencies :

{
  "require": {
    "silex/silex": "~1.1",
    "twig/twig": ">=1.8,<2.0-dev",
    "symfony/twig-bridge": "~2.3",
    "neoxygen/neoclient": "~2.0.0"

  },
  "autoload": {
    "psr-4": {
      "Ikwattro\\SocialNetwork\\": "src"
    }
  }
}

You can download and install Bootstrap to the web/assets folder of your project.

You can find the bootstrap demo app here as well: https://github.com/sitepoint-editors/social-network

Graph Databases in PHP with Neo4j

<< Discover Graph Databases with Neo4j and PHP
Continue reading this article on SitePoint

Nice article, thanks. I’m interesting in graph database and Neo4j including. But have some questions about your article.

  1. You show in article any suggestions, but i don’t understand how they works (magic-magic). How can i customize it’s algorithm. What if i need huge parametric select? Now we are using elasticsearch with some custom plugins for this purposes :smile:
  2. What about performance, resources using and clasterization possibility?
  3. And at all, can it be considered as an alternative to elasticsearch for example in fulltext/facet search?

Hi,

Thanks for reading the article.

  1. No there is no magic, the suggestions are the nodes that you tell Cypher to return, you can also increase the relationship depth to provide friendOfFriend or friendOfFriendOfFriend suggestions.
    Neo4j provide algorithms and it is working very well. However it is a graph database so its purpose is data store and lookup which is not data analysis. You can btw run advanced analysis like explained in this presentation : http://www.slideshare.net/bachmanm/recommendations-with-neo4j-fosdem-2015
  2. Performance is always relative to how optimized is your model and how optimized are your queries. The Neo4j has better performance however when the graph can fit in memory, meaning that it is usual to have at least 16go memory reserved for the Java heap of the Neo4j server.
    Clasterization or clusterization ? Neo4j Enterprise has an HighAvailibility mode, more informations in the documentation.
  3. Currently, no, the fulltext feature are possible but are using an index that will be deprecated in the future. So before Neo4j 2.3 is released, ES is a common add-on we use with neo4j.

Ok, thanks for information.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.