Skip to content

Commit

Permalink
Merge pull request #38 from storyblok/feature/readme-updates
Browse files Browse the repository at this point in the history
Feature/readme updates
  • Loading branch information
joaokamun authored Mar 7, 2022
2 parents f0594fb + 7472efa commit 0507217
Showing 1 changed file with 53 additions and 15 deletions.
68 changes: 53 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
# About
This is the official Storyblok PHP client to easy access the content deliver api and management api.
<div align="center">
<a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=php-client" align="center">
<img src="https://a.storyblok.com/f/88751/1776x360/dc6e51a5fd/sb-php.png" alt="Storyblok Logo">
</a>
<h1 align="center">Storyblok PHP Client</h1>
<p align="center">This is the official <a href="https://www.storyblok.com?utm_source=github.com&utm_medium=referral&utm_campaign=php-client">Storyblok</a> PHP client to easy access the content deliver api and management api.</p>
</div>

<p align="center">
<a href="https://discord.gg/jKrbAMz">
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
</a>
<a href="https://twitter.com/intent/follow?screen_name=storyblok">
<img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
</a><br/>
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=php-client">
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
</a>
</p>

## 🚀 Usage

The content delivery client checks the get parameters _storyblok to get the draft version of a specific story and _storyblok_published to clear the cache.

## Install
### Install

```bash
composer require storyblok/php-client dev-master
```

## Initialization
### Initialization

Initialize the content delivery client with your space draft token for read operations

Expand All @@ -23,7 +42,7 @@ Initialize the management client with your OAuth token from the my account secti
$managementClient = new \Storyblok\ManagementClient('your-storyblok-oauth-token');
```

## Usage of the management client
### Usage of the management client


GET calls
Expand Down Expand Up @@ -58,9 +77,9 @@ $managementClient->delete('spaces/' . $spaceId . '/stories/' . $storyId)->getCod



## Usage of the content delivery client
### Usage of the content delivery client

### Load a Story
#### Load a Story

```php
// Require composer autoload
Expand All @@ -81,7 +100,7 @@ $client->getStoryByUuid('0c092d14-5cd4-477e-922c-c7f8e330aaea');
$data = $client->getBody();
```

### Load a list of Stories
#### Load a list of Stories

```php
// Require composer autoload
Expand All @@ -102,7 +121,7 @@ $client->getStories(
$data = $client->getStoryContent();
```

### Load a list of datasource entries
#### Load a list of datasource entries

```php
// Require composer autoload
Expand All @@ -125,7 +144,7 @@ $nameValueArray = $client->getAsNameValueArray();

```

### Load a list of tags
#### Load a list of tags

```php
// Require composer autoload
Expand All @@ -148,7 +167,7 @@ $stringArray = $client->getAsStringArray();

```

### Load a list of tags and get the Respones Headers
#### Load a list of tags and get the Respones Headers

```php
// Require composer autoload
Expand All @@ -168,7 +187,7 @@ var_dump($client->getHeaders());

```

## Clearing the cache (Optionally if using setCache)
### Clearing the cache (Optionally if using setCache)

In order to flush the cache when the user clicks publish, you need to listen to the published event in javascript or define a webhook in the space settings that clears the cache on your server.

Expand Down Expand Up @@ -198,7 +217,7 @@ $client->deleteCacheBySlug('home');
```


## Generate a navigation tree
### Generate a navigation tree

```php
$tree = $client->editMode()->getLinks()->getAsTree();
Expand All @@ -220,10 +239,29 @@ foreach ($tree as $item) {
echo '</ul>';
```

### Nginx SSI - Server Side Includes
#### Nginx SSI - Server Side Includes

Use the following script if you have Nginx SSI enabled and experience issues with printing the _editable html comments directly to manually parse the Storyblok HTML editable comments: https://gist.github.com/DominikAngerer/ca61d41bae3afcc646cfee286579ad36

## 🔗 Related Links

* **[Storyblok & PHP on GitHub](https://github.com/search?q=org%3Astoryblok+topic%3Aphp)**: Check all of our PHP open source repos;
* **[Storyblok PHP Richtext Renderer](https://github.com/storyblok/storyblok-php-richtext-renderer)**: This package allows you to get an HTML string from the richtext field of Storyblok;
* **[Storyblok Laravel Tutorial](https://www.storyblok.com/tp/add-a-headless-cms-to-laravel-in-5-minutes?utm_source=github.com&utm_medium=referral&utm_campaign=php-client)** : Add a Headless CMS to Laravel in 5 minutes.

## ℹ️ More Resources

### Support

* Bugs or Feature Requests? [Submit an issue](../../../issues/new);

* Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).

### Contributing

Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=php-client).
This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.

### License

This project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
This repository is published under the [MIT](./LICENSE) license.

0 comments on commit 0507217

Please sign in to comment.