PHP code example of apharmony / jsharmony-cms-sdk-php
1. Go to this page and download the library: Download apharmony/jsharmony-cms-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
apharmony / jsharmony-cms-sdk-php example snippets
new CmsRouter($config)
[
'content_path' => null,
//(string) File path to published CMS content files
'redirect_listing_path' => null,
//(string) Path to redirect listing JSON file (relative to content_path)
'default_document' => 'index.html',
//(string) Default Directory Document
'strict_url_resolution' => false,
//(bool) Whether to support URL variations (appending "/" or Default Document)
'passthru_timeout' => 30,
//(int) Maximum number of seconds for passthru request
'cms_clientjs_editor_launcher_path' => '/.jsHarmonyCms/jsHarmonyCmsEditor.js',
//(string) Path where router will serve the client-side JS script that launches CMS Editor
'cms_server_urls' => [],
//Array(string) The CMS Server URLs that will be enabled for Page Editing (set to '*' to enable any remote CMS)
// * Used by page.editorScript, and the getEditorScript function
// * NOT used by jsHarmonyCmsEditor.js - the launcher instead uses access_keys for validating the remote CMS
]
$cmsRouter = new CmsRouter([ 'cms_server_urls' => ['https://cms.example.com'] ]);
$cmsRouter->config['passthru_timeout'] = 60;
[
'onPage' => (function($router, $filename){ }),
//Function to execute on page route
//Return value will be passed as return value of "serve" function
//Default: function($router, $filename){ $router->serveFile($filename); return true; }
'on301' => (function($router, $url){ }),
//Function to execute when a 301 redirect is processed
//Return value will be passed as return value of "serve" function
//Default: function($router, $url){ $router->redirect301($url); return true; }
'on302' => (function($router, $url){ }),
//Function to execute when a 302 redirect is processed
//Return value will be passed as return value of "serve" function
//Default: function($router, $url){ $router->redirect302($url); return true; }
'onPassthru' => (function($router, $url){ }),
//Function to execute when a PASSTHRU redirect is processed
//Return value will be passed as return value of "serve" function
//Default: function($router, $url){ $router->passthru($url)->serve(); return true; }
'on404' => (function($router){ }|null)
//Function to execute when on 404 / Page Not Found. Set to null to continue on Page Not Found.
//Return value will be passed as return value of "serve" function
//Default: null
'onError' => (function($router, $err){ }|null)
//Function to execute when an unexpected error occurs. If null, Exception will be thrown instead.
//Return value will be passed as return value of "serve" function
//Default: null
'serveCmsEditorScript' => (bool)
//Whether the router should serve the CMS Editor Launcher script at config['cms_clientjs_editor_launcher_path']
//Default: true
}