Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

Simple script that includes entry point from external place

  • <?php
  • /**
  •  * Environment setting up ({@link ami_env.php}) usage example.
  •  *
  •  * Simple environment external call.
  •  *
  •  * This script could be located anywhere with access to the Amiro document root
  •  *
  •  * @copyright Amiro.CMS.
  •  * @category  Example
  •  * @package   Environment
  •  * @since     5.12.4
  •  */
  •  
  • // Define new dummy class
  • class MySampleClass {}
  •  
  • $AMI_ENV_SETTINGS array(
  •     'external_call' => true
  • );
  • require '../ami_env.php';
  •  
  • $db new MySampleClass();
  • d::vd($db);
  •  
  • // Save current globals
  • AMI::saveGlobalScope('MyExternalGlobalScope');
  •  
  • // Restore Amiro.CMS globals
  •  
  • // $db is overwritten with Amiro.CMS internal system object
  • d::vd($db);
  •  
  • // We can use any Amiro.CMS API calls here
  • $oSession AMI::getSingleton('env/session');
  • AMI_Registry::set('test'1);
  • $testValue AMI_Registry::get('test');
  • d::vd($testValue);
  •  
  • // Restore initial globals
  • AMI::restoreGlobalScope('MyExternalGlobalScope');
  •  
  • // $db is restored
  • d::vd($db);