Note
This feature is added in PHP Runtime 2.0-383, 2.1-302 and 2.2-115. Use runtimeVersions annotation to require particular version.
PHP Runtime uses PHP annotations to get the current resource schema at run time.
However, if a PHP module is encoded (for example, when using ionCube PHP Encoder), annotations are not available at run-time. In such a case, you can instruct PHP Runtime to obtain the schema from a JSON schema file.
To do so, use the \APS\Loader::preloadClass method as explained in this document.
\APS\Loader::preloadClass($className, $schemaFilePath);
$className corresponding class name (tenant in the example). $schemaFilePath - relative path to the schema file on application endpoint, as ./schemas/tenant.schema.
<?php
require_once("aps/2/runtime.php");
\APS\Loader::preloadClass('tenant', './schemas/tenant.schema');
/**
* Class Tenant
* @type("http://company.com/app/tenant/1.0")
* @implements("http://aps-standard.org/types/core/resource/1.0")
*/
class tenant extends \APS\ResourceBase {
....
If your script is working with several schemas, for example you need to create other resource or access other resources by links, you can preload several schemas, like follows:
<?php
require_once("aps/2/runtime.php");
\APS\Loader::preloadClass('globals', './schemas/globals.schema');
\APS\Loader::preloadClass('VMplan', './schemas/VMplan.schema');
\APS\Loader::preloadClass('VPSplan', './schemas/VPSplan.schema');
/**
* Class Globals
* @type("http://company.com/app/globals/1.0")
* @implements("http://aps-standard.org/types/core/application/1.0")
*/
class globals extends \APS\ResourceBase {
....