-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b102e0c
commit 09d6059
Showing
5 changed files
with
236 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
sidebar_position: 2 | ||
sidebar_label: Storage | ||
title: Getting started with Momento Storage in PHP | ||
description: Learn the basic building blocks for writing PHP code to interact with Momento Storage. | ||
keywords: | ||
- momento | ||
- cache | ||
- caching | ||
- topics | ||
- pubsub | ||
- pub/sub | ||
- eda | ||
- event-driven architecture | ||
- redis | ||
- serverless | ||
- storage | ||
- persistence | ||
- datastore | ||
- database | ||
- duarble | ||
- sdk | ||
- sdks | ||
- api | ||
- examples | ||
- resources | ||
- getting started | ||
- quick start | ||
- server-side | ||
- php | ||
- laravel | ||
- drupal | ||
--- | ||
|
||
import { SdkExampleCodeBlock } from "@site/src/components/SdkExampleCodeBlock"; | ||
// This import is necessary even though it looks like it's un-used; The inject-example-code-snippet | ||
// plugin will transform instances of SdkExampleCodeBlock to SdkExampleCodeBlockImpl | ||
import { SdkExampleCodeBlockImpl } from "@site/src/components/SdkExampleCodeBlockImpl"; | ||
|
||
# Getting Started with Momento Storage in PHP | ||
|
||
If you need to get going quickly with PHP and Momento Storage, this page contains the basic API calls you'll need. | ||
|
||
For more info, you can also see [the PHP SDK on GitHub](https://github.com/momentohq/client-sdk-php). | ||
|
||
### Prerequisites | ||
|
||
* A Momento API Key is required. You can generate one using [the Momento console](https://console.gomomento.com/). | ||
* Installation of PHP 8.0 or higher | ||
* Installation of the [gRPC PHP extension](https://github.com/grpc/grpc/blob/master/src/php/README.md). | ||
* Installation of the [protobuf C extension](https://developers.google.com/google-ads/api/docs/client-libs/php/protobuf#c_implementation) | ||
* Installation of [Composer](https://getcomposer.org/doc/00-intro.md) - A common library and dependency manager for PHP. | ||
|
||
### Configure composer to get the PHP SDK | ||
|
||
Add our repository to your `composer.json` file and our SDK as a dependency: | ||
|
||
```json | ||
{ | ||
"require": { | ||
"momentohq/client-sdk-php": "1.11.1" | ||
} | ||
} | ||
``` | ||
|
||
Run `composer update` to install the necessary prerequisites. | ||
|
||
## Import libraries and connect to return a StorageClient object | ||
|
||
This code sets up the main function, pulls in the necessary imports, and instantiates the StorageClient that will be used to interact with your store. | ||
|
||
<SdkExampleCodeBlock language={'php'} file={'storage-cheat-sheet.php'} /> | ||
|
||
## Create a new store in Momento Storage | ||
Use this function to create a new store in your account. | ||
|
||
<SdkExampleCodeBlock language={'php'} snippetId={'API_Storage_CreateStore'} /> | ||
|
||
## List the names of existing stores in your account | ||
A simple list of the names of stores for the account. | ||
|
||
<SdkExampleCodeBlock language={'php'} snippetId={'API_Storage_ListStores'} /> | ||
|
||
## Write an item to a store | ||
A simple example of doing a put operation. | ||
|
||
<SdkExampleCodeBlock language={'php'} snippetId={'API_Storage_Put'} /> | ||
|
||
## Read an item from a store | ||
This is an example of a simple read operation to get an item from a sore. | ||
|
||
<SdkExampleCodeBlock language={'php'} snippetId={'API_Storage_Get'} /> | ||
|
||
## Delete an item from a store | ||
This is an example of a simple delete operation to remove an item from a store. | ||
|
||
<SdkExampleCodeBlock language={'php'} snippetId={'API_Storage_Delete'} /> | ||
|
||
## Running the code | ||
|
||
You can find complete, working examples in the [PHP SDK GitHub repo examples directory](https://github.com/momentohq/client-sdk-php/blob/main/examples). | ||
|
||
:::info | ||
Beyond these basic API calls check out the [API reference page](/storage/develop/api-reference/index.mdx) for more information on the full assortment of Momento API calls. | ||
::: |
Oops, something went wrong.