strategio / contentio-sdk
PHP SDK for Contentio CRM websites
Installs: 192
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Language:Latte
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.4
- latte/latte: ^2.10
- nette/di: ^3.0
- nette/schema: ^1.2
- nette/utils: ^3.2
- symfony/dotenv: ^6.0
- symfony/http-foundation: ^6.0
- symfony/routing: ^6.0
- tracy/tracy: ^2.9
Requires (Dev)
- phpstan/phpstan: ^1.8
README
(If you read this readme on npmjs.com, switch to https://github.com/strategio-digital/contentio-sdk)
About
-
Contentio-SDK is a fully extendable PHP & JS package for creating custom websites that's communicating with the Contentio REST API.
-
You can use it as "server-side-rendering (php)" AND "client-side-rendering (vue.js)" engine for your e-shop or website.
-
If you don't make any changes, the SDK will render a complete e-shop that will look exactly like https://contentio.store
Installation guide
1. For classic usage
You have to clone another repository rokuc-cz
git clone git@github.com:strategio-digital/rokuc-cz.git <my-project>
rm -rf <my-project>/.git
- Go to second step in "For contributors" and continue.
2. For contributors
git clone git@github.com:strategio-digital/contentio-sdk.git
./project.sh serve
./project.sh app
composer i
composer analyse
yarn && yarn dev
3. After installation
- Classic project: http://localhost:8080
- For contributors: http://localhost:1337
IMPORTANT NOTES FOR OUR CONTRIBUTORS
⚠️💥 Don't forget to yarn publish
when you make changes in these 2 files:
1. package.json
2. yarn.lock
Examples for classic usage
1. Adding custom config file
In www/index.php
$container = (new Bootstrap()) ->projectRootPath(__DIR__ . '/../') ->configure([ __DIR__ . '/../vendor/strategio/contentio-sdk/config/app.neon', //__DIR__ . '/../config/app.neon' // <--- uncomment this ]); $container->getByType(App::class)->run($container);
2. Overriding routes:
In app/config/app.neon
services: #routerFactory: Strategio\Router\RouterFactory # <--- uncomment this
In app/Router/RouterFactory.php
class RouterFactory extends \ContentioSdk\Router\RouterFactory { public function createRoutes(): UrlMatcher { $routes = parent::createRoutes(); // uncomment this ---> /*$this->add('article_detail', '/clanky/{slug}', [ \Strategio\Controller\ArticleController::class, 'index' ]);*/ return $routes; } }
3. Overriding template of any action
In app/Controller/ArticleController.php
class ArticleController extends \ContentioSdk\Controller\ArticleController { #[Template(path: __DIR__ . '/../../view/controller/article.latte')] public function index(string $slug): void { parent::index($slug); } }
4. Making async request to API
public function index(string $slug): void { $this->addRequest('first', 'GET', "article/show-one", [ 'json' => [ 'slug' => $slug, ] ]); $this->addRequest('second', 'GET', "article/show-one", [ 'json' => [ 'slug' => $slug, ] ]); $responses = $this->dispatchRequests('Article Detail'); // first article as array --> $a1 = json_decode($responses['first']->getBody()->getContents(), true); // second article as array --> $a2 = json_decode($responses['second']->getBody()->getContents(), true); $this->template->articles = [$a1, $a2]; }
5. Creating image thumbnail
{varType ContentioSdk\Component\Thumbnail\ThumbGen $thumbGen} {var $thumb = $thumbGen->create('<slug>/article/56/test.png', 500, null, 'SHRINK_ONLY', 80)} <img loading="lazy" src="{$thumb->getSrc()}" width="{$thumb->getWidth()}" height="{$thumb->getHeight()}" alt="...">