Magrathea PHP 2

MagratheaPHP extends Singleton
in package

Base class for a Magrathea project.

It handles paths, configurations, database connections, and environments.

Table of Contents

Properties

$appRoot  : string
$codeFolder  : array<string|int, string>
$magRoot  : string
$versionRequired  : string|null
$instance  : array<string|int, mixed>|null

Methods

__wakeup()  : mixed
AddCodeFolder()  : MagratheaPHP
Adds one or more code folders for the autoloader.
AddFeature()  : MagratheaPHP
Adds feature folders based on the application root.
AppPath()  : MagratheaPHP
Sets the application's root path.
AppVersion()  : string
Gets the version of the application from the `version` file in the project root.
Connect()  : MagratheaPHP
Connects to the database using credentials from the configuration.
Debug()  : MagratheaPHP
Enables the debugger.
Dev()  : MagratheaPHP
Sets the environment to development mode.
GetAppRoot()  : string
Returns the root path of the application.
GetConfigRoot()  : string
Gets the path to the configuration directory.
GetDB()  : Database
Gets the singleton instance of the Database object.
GetDocumentationLink()  : string
Returns the link to Magrathea's official documentation.
GetMagratheaRoot()  : string
Gets the root directory of the MagratheaPHP library.
Instance()  : static|Singleton
Load()  : MagratheaPHP
Starts Magrathea
LoadVendor()  : void
Includes the Composer autoloader.
MinVersion()  : MagratheaPHP
Checks if the current Magrathea version meets a minimum requirement.
MockClass()  : static|Singleton
Prod()  : MagratheaPHP
Sets the environment to production mode.
SetInstance()  : mixed
StartDB()  : MagratheaPHP
Connects to the database. Alias for `Connect()`.
StartSession()  : MagratheaPHP
Starts a PHP session if one is not already active.
Test()  : void
A simple test function to check if MagratheaPHP is working.
Version()  : string
Gets Magrathea Version
__clone()  : mixed
__construct()  : mixed

Properties

$appRoot

public string $appRoot = ""

Root of the application.

$codeFolder

public array<string|int, string> $codeFolder = []

Folders to be included in the autoloader.

$magRoot

public string $magRoot = ""

Root of the Magrathea Structure (usually one level above appRoot).

$versionRequired

public string|null $versionRequired = null

Minimum version of Magrathea required.

$instance

protected static array<string|int, mixed>|null $instance = []

Methods

AddCodeFolder()

Adds one or more code folders for the autoloader.

public AddCodeFolder(string ...$folder) : MagratheaPHP
Parameters
$folder : string

One or more folder paths to add.

Return values
MagratheaPHP

AddFeature()

Adds feature folders based on the application root.

public AddFeature(string ...$features) : MagratheaPHP

For each feature, it adds features/[name] and features/[name]/Base.

Parameters
$features : string

One or more feature names.

Return values
MagratheaPHP

AppPath()

Sets the application's root path.

public AppPath(string $path) : MagratheaPHP

Also defines the magRoot as the parent directory.

Parameters
$path : string

Root path of the project.

Return values
MagratheaPHP

AppVersion()

Gets the version of the application from the `version` file in the project root.

public AppVersion() : string
Return values
string

Application version, or "???" if not found.

GetAppRoot()

Returns the root path of the application.

public GetAppRoot() : string
Return values
string

Application root path.

GetConfigRoot()

Gets the path to the configuration directory.

public GetConfigRoot() : string
Tags
throws
MagratheaConfigException

If magRoot is not set.

Return values
string

The path to the /configs directory.

GetDB()

Gets the singleton instance of the Database object.

public GetDB() : Database
Return values
Database

The database instance.

Returns the link to Magrathea's official documentation.

public static GetDocumentationLink() : string
Return values
string

URL for the documentation.

GetMagratheaRoot()

Gets the root directory of the MagratheaPHP library.

public GetMagratheaRoot() : string
Return values
string

The path to the MagratheaPHP source directory.

LoadVendor()

Includes the Composer autoloader.

public static LoadVendor() : void

MinVersion()

Checks if the current Magrathea version meets a minimum requirement.

public MinVersion(string $version[, bool $throwEx = false ]) : MagratheaPHP
Parameters
$version : string

Minimum version required (e.g., "2.1.0").

$throwEx : bool = false

If true, throws a MagratheaException if the version is not met. Otherwise, it displays an error message.

Tags
throws
MagratheaException

(code 206) if the version is incompatible and $throwEx is true.

Return values
MagratheaPHP

SetInstance()

public SetInstance(mixed $inst) : mixed
Parameters
$inst : mixed

Test()

A simple test function to check if MagratheaPHP is working.

public static Test() : void

Version()

Gets Magrathea Version

public static Version() : string
Return values
string

version

__construct()

private final __construct() : mixed

        
On this page

Search results