If you have decided to leverage the power of the worlds’ leading graph database as a PHP developer or team, getting started can look incredibly difficult. Do you use Docker, bare metal solutions, do you host multiple instances at once for horizontal scaling? How will you make sure the data is secure? Does it need to become part of your CI? Will your team be able to develop locally with their own private instance? These questions exponentially increase the complexity, putting a massive drain on your teams’ resources without even getting started.
Luckily, there is an easy way to quickly build an excellent future-proof web app with Neo4j – and it’s called Neo4j AuraDB.
Neo4j AuraDB is a cloud solution that takes away the headaches when building web apps. All you need to get started is your trusty old PHP installation and an email to sign up for the free Neo4j Aura instance; no credit card required.
Neo4j AuraDB is a great fit if you care about:
- an effortless installation
- built-in scalability, reliability and security
- focusing on developing your business solution
Quickly get started by following these two steps!
Step 1: Get Your Free Neo4j AuraDB instance
All you need to get started is your trusty old PHP installation and an email to sign up for the free Neo4j AuraDB instance; no credit card required.
Signing up for a free database instance is super convenient; simply navigate to this page with your browser.
You can quickly register with Google, but any email address will do.
If you want to follow along with a built-in example, make sure to select the starting dataset: “learn about graphs with a movie dataset.” This is not required of course.
Once you have created your database. You will receive your credentials. Make sure to store them for later as you will need them to connect from PHP!
You will be redirected to your dashboard.
You can then open it with the Neo4j browser and start querying to your hearts’ contempt!
Now we need to get ready with our PHP setup!
Step 2: Install the Neo4j PHP lient
The PHP client can be quickly installed with this command of composer:
Congratulations! You are almost done creating your connections with Neo4j AuraDB 🎉
Remember me warning you to store your Neo4j AuraDB credentials? I hope you listened as we need them right now. Build your client with your credentials like this:
WARNING: make sure to use systems like environment variables to detach your login variables from your code.
The ClientBuilder::addDriver uses three parameters:
- an alias for the driver (‘aura’)
- the URI to point to the database (you can find this one in your dashboard as described in step 1)
- the authentication logic
This client can now be used to freely query your database to build an application.
This configuration is straightforward to set up but is incredibly versatile! You can use it to connect to cluster deployments, Neo4j AuraDB or single instances without any trouble. This truly makes your app future-proof!
You can now start querying any way you like:
You can also refer to the Neo4j Movies example project for more in depth use cases:
I can sit here as the author of the driver and dive deep into the technical details of the driver. But I will spare you these details for another day. You can already read about some of them here:
We are putting together some live streams and videos to tutor the basics of the driver, Neo4j and PHP. Stay tuned!
The Neo4j PHP ecosystem is currently experiencing a true renaissance. We are working hard on reviving the integrations with Laravel and Symfony, while other people are building a stand-alone Cypher query builder! Feel free to follow along or help us along the way.
Get AuraDB Free Now