Skip to content

Commit 49a5a8c

Browse files
authored
Merge pull request #80 from sqlitecloud/feat/php-updates
Added clarifications to PHP Intro
2 parents 353de7c + 2743fb2 commit 49a5a8c

3 files changed

Lines changed: 59 additions & 27 deletions

File tree

sqlite-cloud/quick-start-php-laravel.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ composer require sqlitecloud/sqlitecloud
8686
6. **Query data**
8787

8888
- Replace the code in `app/Http/Controllers/AlbumController.php` with the following snippet.
89-
- In your SQLite Cloud account dashboard, click on a Node, copy the Connection String, and replace `<your-connection-string>` below.
89+
- In your SQLite Cloud account dashboard, click on `Show connection strings`, copy the Connection String, and replace `<your-connection-string>` below.
9090
- The `index` method will:
9191
- connect to and query the database,
9292
- create an array of arrays `albums` containing each returned album's title and artist,

sqlite-cloud/sdks/php/introduction.mdx

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,35 @@ status: publish
66
slug: sdk-php-introduction
77
---
88

9-
10-
[![Test and QA][test-qa-img]][test-qa-url]
11-
[![codecov][codecov-img]][codecov-url]
12-
[![Packagist Version][packagist-version-img]][packagist-url]
13-
[![PHP][php-img]][packagist-url]
9+
This powerful package provides methods that simplify performing database operations in PHP applications, making it easier than ever to work with SQLite in the cloud. We encourage all users to log encountered issues in the [SDK’s issues backlog](https://github.com/sqlitecloud/sqlitecloud-php/issues).
1410

1511
## Install
1612

13+
- Run the following command to initialize a PHP project and install the SDK.
14+
1715
```bash
1816
$ composer require sqlitecloud/sqlitecloud
1917
```
2018

21-
SQLite Cloud is a powerful PHP package that allows you to interact with the SQLite Cloud database seamlessly. It provides methods for various database operations.
22-
This package is designed to simplify database operations in PHP applications, making it easier than ever to work with SQLite Cloud.
19+
## Configure your database connection
20+
21+
- In your SQLite Cloud account dashboard, click on `Show connection strings`, copy the Connection String, and replace `<your-connection-string>` below.
22+
23+
```php
24+
$sqlite->connectWithString("<your-connection-string>");
25+
```
26+
27+
- You can modify the connection string to include the name of the database to query.
28+
- Here, the provided port (`8860`) and database (`chinook.sqlite`) will query the sample dataset that comes pre-loaded with SQLite Cloud. Replace to query your own datasets.
29+
30+
```php
31+
$sqlite->connectWithString('sqlitecloud://{hostname}:8860/chinook.sqlite?apikey={apikey}');
32+
```
33+
34+
## Connect and query
2335

24-
## Example
36+
- Include the following snippet in a new `example.php` file.
37+
- NOTE: `$sqlite->execute("USE DATABASE {$db_name}");` is only necessary if your connection string does NOT specify the name of the database to query.
2538

2639
```php
2740
<?php
@@ -31,18 +44,13 @@ require_once 'vendor/autoload.php';
3144
use SQLiteCloud\SQLiteCloudClient;
3245
use SQLiteCloud\SQLiteCloudRowset;
3346

34-
// Open the connection to SQLite Cloud
3547
$sqlite = new SQLiteCloudClient();
36-
$sqlite->connectWithString('sqlitecloud://myhost.sqlite.cloud:8860?apikey=myapikey');
48+
$sqlite->connectWithString("<your-connection-string>");
3749

38-
// You can autoselect the database during the connect call
39-
// by adding the database name as path of the SQLite Cloud
40-
// connection string, eg:
41-
// $sqlite->connectWithString("sqlitecloud://myhost.sqlite.cloud:8860/mydatabase?apikey=myapikey");
4250
$db_name = 'chinook.sqlite';
4351
$sqlite->execute("USE DATABASE {$db_name}");
4452

45-
/** @var SQLiteCloudRowset */
53+
/** @var SQLiteCloudRowset */
4654
$rowset = $sqlite->execute('SELECT * FROM albums WHERE ArtistId = 2');
4755

4856
printf('%d rows' . PHP_EOL, $rowset->nrows);
@@ -54,18 +62,35 @@ for ($i = 0; $i < $rowset->nrows; $i++) {
5462
$sqlite->disconnect();
5563
```
5664

57-
## PHP Admin
58-
To better understand the PHP APIs usage we developed a simple PHP Admin interface that can be used to administer any SQLite Cloud node.
65+
- Run your app!
66+
67+
```
68+
php example.php
69+
```
70+
71+
## PHP Admin Dashboard
72+
73+
You can use SQLite Cloud's simplified PHP Admin interface to administer any node.
74+
75+
- Clone the PHP SDK, install lock file dependencies, and run the dashboard locally.
76+
77+
```bash
78+
git clone https://github.com/sqlitecloud/sqlitecloud-php.git
79+
80+
composer update # or composer install
81+
cd admin
82+
php -S localhost:8000
83+
```
84+
85+
- Login as your admin user.
86+
- In your SQLite Cloud account dashboard, click on `Show connection strings`, copy the Deployment string, and paste in `Hostname`.
87+
- In your dashboard left nav, select Settings, then Users. Copy your admin user's username and paste in `Username`.
88+
- In your User's row, click the down chevron, then Edit. Enter a Password and Save. Paste in `Password`.
5989

60-
You can login using admin credentials:
6190
![PHP Admin Login](@docs-website-assets/php/admin_login.png)
6291

63-
And then administer your node with a convenient user interface:
6492
![PHP Admin Overview](@docs-website-assets/php/admin_overview.png)
6593

66-
PHP Admin source code is available in a [GitHub repo](https://github.com/sqlitecloud/sqlitecloud-php/tree/main/admin).
67-
68-
## More
6994
[test-qa-img]: https://github.com/sqlitecloud/sqlitecloud-php/actions/workflows/deploy.yaml/badge.svg?branch=main
7095
[test-qa-url]: https://github.com/sqlitecloud/sqlitecloud-php/actions/workflows/deploy.yaml
7196
[codecov-img]: https://codecov.io/gh/sqlitecloud/sqlitecloud-php/graph/badge.svg?token=3FFHULGCOY

sqlite-cloud/sdks/swift/introduction.mdx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,30 @@ let package = Package(
2727

2828
1. **RECOMMENDED**: Use the `apikey` connection string.
2929

30-
In your SQLite Cloud account dashboard, click on `Show connection strings`, copy the Connection String, and replace `<your-connection-string>` below.
30+
- In your SQLite Cloud account dashboard, click on `Show connection strings`, copy the Connection String, and replace `<your-connection-string>` below.
3131

3232
```swift
3333
let configuration = SQLiteCloudConfig(connectionString: "<your-connection-string>")
3434
```
3535

36+
- You can modify the connection string to include the name of the database to query.
37+
38+
```swift
39+
let configuration = SQLiteCloudConfig(connectionString: "sqlitecloud://{hostname}:8860/{database}?apikey={apikey}")
40+
```
41+
3642
2. Use a parameterized connection string.
3743

38-
- In your SQLite Cloud account dashboard, click on a Node, copy the Deployment string, and replace `{hostname}` below.
44+
- In your SQLite Cloud account dashboard, click on `Show connection strings`, copy the Deployment string, and replace `{hostname}` below.
3945
- In your dashboard left nav, select Settings, then Users. Copy your username and replace `{username}`.
4046
- In your User's row, click the down chevron, then Edit. Enter a Password and Save. Replace `{password}`.
41-
- The provided port and database will query the sample dataset that comes pre-loaded with SQLite Cloud. Replace both for your own datasets.
47+
- Here, the provided port (`8860`) and database (`chinook.sqlite`) will query the sample dataset that comes pre-loaded with SQLite Cloud. Replace to query your own datasets.
4248

4349
```swift
4450
let configuration = SQLiteCloudConfig(connectionString: "sqlitecloud://{username}:{password}@{hostname}:8860/chinook.sqlite")
4551
```
4652

47-
3. Pass each connection string parameter.
53+
3. Pass each connection string parameter explicitly.
4854

4955
```swift
5056
let configuration = SQLiteCloudConfig(hostname: {hostname}, username: {username}, password: {password}, port: .default)
@@ -53,6 +59,7 @@ let configuration = SQLiteCloudConfig(hostname: {hostname}, username: {username}
5359
## Connect and query
5460

5561
- The following snippet includes variable types, which may be optional for your app.
62+
- NOTE: `USE DATABASE chinook.sqlite;` is only necessary in the query if your `configuration` does not specify the name of the database to query.
5663
- Once you've incorporated the following, build and run your app!
5764

5865
```swift

0 commit comments

Comments
 (0)