Skip to content

Commit fb5336d

Browse files
authored
Merge pull request #18 from ondrejfuhrer/patch-1
Improving the README with php highlighting
2 parents 19c0811 + b23df4a commit fb5336d

File tree

1 file changed

+38
-29
lines changed

1 file changed

+38
-29
lines changed

README.md

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ To use the PHP SDK, you need to perform the following steps:
2020

2121
To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.
2222

23-
use Contentstack\Contentstack;
24-
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
23+
```php
24+
use Contentstack\Contentstack;
25+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
26+
```
2527

2628

2729
#### Download and install library:
@@ -32,9 +34,11 @@ To use the PHP SDK, you need to perform the following steps:
3234

3335
To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.
3436

35-
use Contentstack\Contentstack;
36-
include_once "contentstack/contentstack.php";
37-
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
37+
```php
38+
use Contentstack\Contentstack;
39+
include_once "contentstack/contentstack.php";
40+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
41+
```
3842

3943

4044
### Key Concepts for using Contentstack
@@ -59,8 +63,7 @@ Assets refer to all the media files (images, videos, PDFs, audio files, and so o
5963

6064
A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
6165

62-
63-
66+
6467

6568
### Contentstack PHP SDK: 5-minute Quickstart
6669

@@ -69,31 +72,35 @@ Install the library using [Composer](https://packagist.org/packages/contentstack
6972

7073
composer require contentstack/contentstack
7174

75+
7276
To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.
7377

74-
use Contentstack\Contentstack;
75-
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
78+
```php
79+
use Contentstack\Contentstack;
80+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
81+
```
7682

7783
To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Delivery Token.
7884

79-
85+
8086

8187
#### Querying content from your stack
8288

8389
To find all entries of a content type, use the query given below:
8490

85-
$result = $stack->ContentType(CONTENT_TYPE_UID)->Query()->toJSON()->includeCount()->includeContentType()->find()
86-
// $result[0] - array of entries
87-
// $result[1] - content type
88-
// $result[2] - count of the entries
89-
90-
91-
91+
```php
92+
$result = $stack->ContentType(CONTENT_TYPE_UID)->Query()->toJSON()->includeCount()->includeContentType()->find();
93+
// $result[0] - array of entries
94+
// $result[1] - content type
95+
// $result[2] - count of the entries
96+
```
9297

9398
To fetch a specific entry from a content type, use the following query:
9499

95-
$result = $stack->ContentType(CONTENT_TYPE_UID)->Entry(ENTRY_UID)->toJSON()->fetch()
96-
// $result - entry object
100+
```php
101+
$result = $stack->ContentType(CONTENT_TYPE_UID)->Entry(ENTRY_UID)->toJSON()->fetch();
102+
// $result - entry object
103+
```
97104

98105
### Advanced Queries
99106

@@ -115,22 +122,24 @@ You can use the Image Delivery API functions in this SDK as well. Here are a few
115122

116123
// set the image quality to 100.
117124

118-
imageUrl = Stack->imageTransform(imageUrl, array(
119-
'quality'=> 100));
125+
```php
126+
$imageUrl = $stack->imageTransform(imageUrl, array('quality' => 100));
127+
```
120128

121129
// resize the image by specifying width and height.
122130

123-
imageUrl = Stack->imageTransform(imageUrl, array(
124-
'width'=> 100,
125-
'height'=> 100
126-
));
131+
```php
132+
$imageUrl = $stack->imageTransform(imageUrl, array(
133+
'width' => 100,
134+
'height' => 100
135+
));
136+
```
127137

128138
// enable auto optimization for the image.
129139

130-
imageUrl = Stack->imageTransform(imageUrl, array(
131-
'auto'=> 'webp'
132-
))
133-
140+
```php
141+
$imageUrl = $stack->imageTransform(imageUrl, array('auto' => 'webp'));
142+
```
134143

135144

136145
### Helpful Links

0 commit comments

Comments
 (0)