At the end of this guide, you will have created a simple PHP
Hello, World! program that connects to the Memgraph database and executes simple queries.
To follow this guide, you will need:
- A running Memgraph instance. If you need to set up Memgraph, take a look at the Installation guide.
- A basic understanding of graph databases and the property graph model.
- Composer, a tool for dependency management in PHP. Instructions on how to install Composer can be found here.
We recommend using the Bolt driver for PHP.
We'll be using a very simple PHP script in combination with Composer to demonstrate how to connect to a running Memgraph instance.
Let's jump in and connect a simple program to Memgraph.
1. Create a new directory for your application, for example
/MyApp and position yourself in it.
2. Create a
index.php file and add the following code to it:
3. Create a
composer.json file with the following contents:
4. Execute the next command to install the needed dependencies:
5. Start the application with the following command:
You should see an output similar to the following:
For real-world examples of how to use Memgraph, we suggest you take a look at the Tutorials page. You can also browse through the Database functionalities section to get an overview of all the functionalities Memgraph offers.
Visit the Getting help page in case you run into any kind of problem or you have additional questions.