# final class \SmartEnvironment
{ } ::

Class: Smart Environment - provides the methods for the Smart.Framework environment.

- Language: PHP
- Located at: lib/framework/lib_security.php
- Package: @Core
- Namespace: \
- Class Name: SmartEnvironment
- Version: v.20240118
- Depends: optional-constants: SMART_FRAMEWORK_DEBUG_MODE, SMART_FRAMEWORK_INTERNAL_DEBUG, SMART_FRAMEWORK_ENV, SMART_FRAMEWORK_ADMIN_AREA, SMART_FRAMEWORK_RUNTIME_MODE
- Hints: It is recommended to use the methods in this class instead of PHP native methods whenever is possible because this class will offer Long Term Support and the methods will be supported even if the behind PHP methods can change over time, so the code would be easier to maintain.
- Usage: static object: Class::method() - This class provides only STATIC methods

## class Methods

public static function isATKEnabled ( ) {} :: BOOL
@return: {BOOL} TRUE if enabled ; FALSE if not
Returns TRUE if ATK (Auth Tokens) are Enabled
Will test for the current area only
public static function is2FAEnabled ( ) {} :: BOOL
@return: {BOOL} TRUE if enabled ; FALSE if not
Returns TRUE if 2FA is Enabled
Will test for the current area only
public static function getArea ( ) {} :: STRING
@return: {STRING} 'idx' for Index Area ; 'adm' for Admin Area ; 'tsk' for Task Area
Returns the Environment Area
public static function isAdminArea ( ) {} :: BOOL
@return: {BOOLEAN} if is ADMIN area will return TRUE else will return FALSE
Test if Admin (service) Area
For services running over admin.php / task.php will return TRUE ; for services running over index.php will return FALSE
public static function isTaskArea ( ) {} :: BOOL
@return: {BOOLEAN} if is TASK area will return TRUE else will return FALSE
Test if Task (service) Area (implies also to be isAdminArea() as well)
Task area is an Admin area with some unrestricted features ; it must be restricted by IP to avoid security issues ; it is designed to be used mostly in development but can be used in production by restricting the access to this area using the init setting: SMART_FRAMEWORK_RUNTIME_TASK_ALLOWED_IPS
For services running over task.php will return TRUE ; for services running over admin.php / index.php will return FALSE
public static function ifDevMode ( ) {} :: BOOL
@return: {BOOLEAN} if is Production Environment will return TRUE else will return FALSE (if FALSE it is always considered the Development Environment)
Test if Production Environment as set in init.php by SMART_FRAMEWORK_ENV
Production Environment (SMART_FRAMEWORK_ENV = 'prod') differ from Development Environment (SMART_FRAMEWORK_ENV = 'dev') especially by the fact that Production Environment avoids to display any error (will just log errors and warnings and will not log notices)
Using this method to detect if Production or Development Environment the code can have a dual behaviour Production vs Development
public static function ifDebug ( ) {} :: BOOL
@return: {BOOLEAN} if Debug is ON will return TRUE, else will return FALSE
Test if DEBUG is ON
Debug can be enabled on both: Production or Development Environments, by setting; define('SMART_FRAMEWORK_DEBUG_MODE', true); // init.php
Using Debug in Production Environment must be enabled per one IP only that can have access to that feature to avoid expose sensitive data to the world !!!
Ex: if(myIPIsDetected()) { define('SMART_FRAMEWORK_DEBUG_MODE', true); } // in init.php, for a Production Environment

## class Properties

## class Constants

## Sample code: PHP

`

    <?php

    // Usage example:
     Smart::some_method_of_this_class(...);

    // #end php code

`

documentation generated on: 2024-12-16 16:53:44 +0000

Smart.Framework © 2009-2024 unix-world.org