Skip to content

Commit f77905f

Browse files
committed
Merge branch 'master' into embeddec_items
2 parents a97accd + 27f8a65 commit f77905f

21 files changed

+205
-101
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
## CHANGELOG
33
------------------------------------------------
44

5+
## Version 2.0.0
6+
###### Date: 02-Apr-2021
7+
### New Feature
8+
- Sync API support added
9+
### Enhancement
10+
- Added PSR 4 Standardized implementation.
11+
12+
------------------------------------------------
13+
14+
## Version 1.8.1
15+
###### Date: 17-Mar-2021
16+
### Bug Fix
17+
- Updated addQuery method to pass non encoded Json to Query object
18+
- Removed parameter check on functions those pass default values.
19+
20+
------------------------------------------------
21+
522
## Version 1.8.0
623
###### Date: 5-Dec-2020
724
### New Feature

README.md

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ 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);
25-
26-
23+
```php
24+
use Contentstack\Contentstack;
25+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
26+
```
27+
For Setting the European Region:
28+
If you want to set and use European region, refer to the code below:
29+
30+
```php
31+
use Contentstack\Contentstack;
32+
use Contentstack\ContentstackRegion;
33+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME, array('region'=> ContentstackRegion.EU));
34+
```
2735
#### Download and install library:
2836
To use the PHP SDK, you need to perform the following steps:
2937

@@ -32,9 +40,11 @@ To use the PHP SDK, you need to perform the following steps:
3240

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

35-
use Contentstack\Contentstack;
36-
include_once "contentstack/contentstack.php";
37-
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
43+
```php
44+
use Contentstack\Contentstack;
45+
include_once "contentstack/contentstack.php";
46+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
47+
```
3848

3949

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

6070
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).
6171

62-
63-
72+
6473

6574
### Contentstack PHP SDK: 5-minute Quickstart
6675

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

7079
composer require contentstack/contentstack
7180

81+
7282
To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.
7383

74-
use Contentstack\Contentstack;
75-
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
84+
```php
85+
use Contentstack\Contentstack;
86+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
87+
```
7688

7789
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.
7890

79-
91+
8092

8193
#### Querying content from your stack
8294

8395
To find all entries of a content type, use the query given below:
8496

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-
97+
```php
98+
$result = $stack->ContentType(CONTENT_TYPE_UID)->Query()->toJSON()->includeCount()->includeContentType()->find();
99+
// $result[0] - array of entries
100+
// $result[1] - content type
101+
// $result[2] - count of the entries
102+
```
92103

93104
To fetch a specific entry from a content type, use the following query:
94105

95-
$result = $stack->ContentType(CONTENT_TYPE_UID)->Entry(ENTRY_UID)->toJSON()->fetch()
96-
// $result - entry object
106+
```php
107+
$result = $stack->ContentType(CONTENT_TYPE_UID)->Entry(ENTRY_UID)->toJSON()->fetch();
108+
// $result - entry object
109+
```
97110

98111
### Advanced Queries
99112

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

116129
// set the image quality to 100.
117130

118-
imageUrl = Stack->imageTransform(imageUrl, array(
119-
'quality'=> 100));
131+
```php
132+
$imageUrl = $stack->imageTransform(imageUrl, array('quality' => 100));
133+
```
120134

121135
// resize the image by specifying width and height.
122136

123-
imageUrl = Stack->imageTransform(imageUrl, array(
124-
'width'=> 100,
125-
'height'=> 100
126-
));
137+
```php
138+
$imageUrl = $stack->imageTransform(imageUrl, array(
139+
'width' => 100,
140+
'height' => 100
141+
));
142+
```
127143

128144
// enable auto optimization for the image.
129145

130-
imageUrl = Stack->imageTransform(imageUrl, array(
131-
'auto'=> 'webp'
132-
))
133-
146+
```php
147+
$imageUrl = $stack->imageTransform(imageUrl, array('auto' => 'webp'));
148+
```
134149

135150

136151
### Helpful Links

composer.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
"require-dev": {
2828
"phpunit/phpunit": "^9.0",
2929
"phpunit/php-code-coverage": "^8.0",
30-
"sami/sami": "^4.1",
31-
"contentstack/utils": "dev-master"
30+
"code-lts/doctum": "^5.3"
3231
},
33-
"require": {
34-
"php" : ">=5.5.0"
32+
"scripts": {
33+
"generate:docs": "vendor/bin/doctum.php update ./config.php",
34+
"test": "vendor/bin/phpunit"
3535
},
36-
"repositories": [
37-
{
38-
"type": "path",
39-
"url": "../contentstack-utils-php/"
40-
}
41-
]
36+
"require": {
37+
"php" : ">=5.5.0",
38+
"contentstack/utils": "^1.0"
39+
}
4240
}

config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
return new Sami\Sami('/Users/uttamukkoji/Documents/php/contentstack-php/src');
3+
return new Doctum\Doctum('./src');
44

src/config/index.php renamed to src/Config/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
define('ENTRIES', '/entries/');
2626
define('ASSETS', '/assets/');
2727
define('ENVIRONMENTS', '/environments/');
28+
define('SYNC', '/stacks/sync/');

src/contentstack.php renamed to src/Contentstack.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Contentstack\Utils\Utils;
1919
use Contentstack\Utils\Model\Option;
2020

21-
require_once __DIR__ . '/lib/models/stack.php';
2221

2322
/**
2423
* Contentstack abstract class to provide access to Stack Object
@@ -39,16 +38,17 @@ abstract class Contentstack
3938
* @param string $api_key : Contentstack Stack API KEY.
4039
* @param string $access_token : Contentstack Stack ACCESS TOKEN.
4140
* @param string $environment : Environment Name.
41+
* @param array $config : Stack Configuration to provide region.
4242
* @param ContentstackRegion $region : Region name of Contentstack.
43-
*
43+
4444
* @return Stack
4545
* */
4646
public static function Stack($api_key = '',
4747
$access_token = '',
4848
$environment = '',
49-
$region = ''
49+
$config = array('region'=> '')
5050
) {
51-
return new Stack($api_key, $access_token, $environment, $region);
51+
return new Stack($api_key, $access_token, $environment, $config);
5252
}
5353

5454
public static function renderContent(string $content, Option $option): string
File renamed without changes.
File renamed without changes.

src/lib/models/assets.php renamed to src/Stack/Assets.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@
1414
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
1515
* @link https://pear.php.net/package/contentstack
1616
* */
17-
namespace Contentstack\Stack\Assets;
17+
namespace Contentstack\Stack;
1818

19-
require_once __DIR__ . "/../../Support/helper.php";
19+
require_once __DIR__ . "/../Support/helper.php";
2020

21-
use Contentstack\Stack\ContentType\Query\Query;
22-
use Contentstack\Stack\ContentType\BaseQuery\BaseQuery;
21+
use Contentstack\Stack\ContentType\Query;
22+
use Contentstack\Stack\BaseQuery;
2323
use Contentstack\Support\Utility;
2424

25-
26-
require_once __DIR__.'/query.php';
27-
require_once __DIR__."/base_query.php";
28-
require_once __DIR__."/../../Support/Utility.php";
29-
30-
3125
/**
3226
* Assets refer to all the media files (images, videos, PDFs,
3327
* audio files, and so on) uploaded in your Contentstack

src/lib/models/base_query.php renamed to src/Stack/BaseQuery.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* @link https://pear.php.net/package/contentstack
1515
* */
1616

17-
namespace Contentstack\Stack\ContentType\BaseQuery;
17+
namespace Contentstack\Stack;
1818
use Contentstack\Support\Utility;
1919

20-
require_once __DIR__ . "/../../Support/helper.php";
21-
require_once __DIR__."/../../Support/Utility.php";
20+
require_once __DIR__ . "/../Support/helper.php";
21+
2222
/**
2323
* BaseQuery
2424
* Base Class where all the Queries will be created
@@ -365,9 +365,10 @@ public function includeContentType()
365365
public function includeEmbeddedItems()
366366
{
367367
$this->queryObject->_query = call_user_func(
368-
'contentstackAddBoolean',
368+
'contentstackReferences',
369369
'include_embedded_items',
370-
$this->queryObject->_query
370+
$this->queryObject->_query,
371+
["BASE"]
371372
);
372373
return $this->queryObject;
373374
}

0 commit comments

Comments
 (0)