# Connecting to SurrealDB

Initialise the SurrealDB PHP SDK, connect to an instance, and select a namespace and database.

This guide shows how to initialise version 1 of the SurrealDB PHP SDK and connect to an instance. If you have not installed the SDK yet, see the [installation guide](/docs/reference/php/v1/installation.md).

**Composer**

Before we can make use of any of the packages we have installed for our project, we need to include the `autoload.php` file in our project.
		This file is generated by Composer and it contains all the classes and dependencies that we have installed in our project.
		```php
		include_once __DIR__ . '/vendor/autoload.php';
		```

When we have imported the `Surreal` class, we can initialise a new instance of SurrealDB.
After this is done we can make use of certain methods to interact with the database.

```php
$db = new Surreal();
```

Then we connect to the database. The `connect` method takes the URL of
the database as an argument. The URL can be either `http` or `ws` protocol.

**HTTP**

		```php
		$db->connect("http://127.0.0.1:8000/rpc");
		```

**WebSocket**

		```php
		$db->connect("ws://127.0.0.1:8000/rpc");
		```

In order to send queries to the database,
we need to set the `namespace` and `database` for the current connection you want
to interact with.

```php
$db->use([
	"namespace" => "main",
	"database" => "main"
]);
```

We should now be successfully connected to the database. In the next article we will cover authenticating our connection.
