Menu

## Pionia

### Table of Contents

#### Packages

Pionia
Http
Middlewares

#### Interfaces

ApplicationContract
AuthenticationChainContract
AuthenticationContract
  Authentication contract.
BaseSwitchContract
CommandContract
CorsContract
IsolatableContract
KernelContract
MiddlewareContract
NewLineAware
ProviderContract
ServiceContract
DatabaseDriverInterface
TemplateEngineInterface

#### Classes

AuthService
  Base Service for generic services
CategoryService
  Base Service for generic services
SampoloService
  Adds the retrieve/details, create, list, update, random and delete actions to the service.
MainSwitch
  This is the base class for the API service switch. It is used to switch between different services based on the request data.
AuthenticationBackend
  Base class for other Authentication backend to inherit.
AuthenticationChain
  Authentication chain.
ContextUserObject
  This is the context object holding the current session
PostAuthRunEvent
  Event fired after the authentication chain has been run
PreAuthRunEvent
  Event fired before the authentication chain has been run
Sessions
  This class is responsible for handling all session related operations
EnvResolver
PioniaApplication
AppProvider
  Base class for service providers.
BaseProvider
  Base class for service providers.
CacheDeleteCommand
ClearCacheCommand
PruneCacheCommand
ListAliasCommand
BuildFrontendCommand
  Builds and hosts the frontend in our app server for production
CleanBuildCommand
  Cleans all build files that were formerly added via building.
DropFrontendCommand
  Drops an entire frontend
ScaffoldFrontendCommand
  Scaffolds any frontend project in the right directory using a package manage of choice and a frontend framework of choice.
CreateMiddleware
  For Creating a new middleware in the middlewares directory by running `pionia gen:middleware {name}`
GenerateAuthenticationBackend
  For Creating a new authentication backend in the authenticationBackends directory by running `pionia gen:auth {name}`
GenerateCommand
  This command is used to generate a new custom command.
GenerateService
  For Creating a new service in the services directory by running `pionia gen:service {name}`
GenerateSwitch
  Creates a new Pionia Switch in Switches directory by running `pionia gen:switch {version}`
StartServer
  For starting the command line server. This should be good choice only in development
PioniaCache
  Pionia caching port of the Psr16Cache class provided by Symfony.
PioniaCacheAdaptor
Arrayable
Carbon
HighOrderTapProxy
HighOrderWhenProxy
BaseCommand
OutputStyle
Parser
PioniaCors
Event
PioniaEventDispatcher
BaseException
  This is the base exception class that all other exceptions must extend.
CommandException
  This exception is thrown when a cli command fails.
ControllerException
  This exception is thrown controller parsing fails in anyway
DatabaseException
  This exception is thrown when an error occurs during database connection establishment.
FailedRequiredException
  This exception is thrown when a required field is not provided in the request
InvalidDataException
  This exception is thrown when a regular expression fails and we are in the exceptions mode.
InvalidProviderException
  This exception is thrown when a cli command fails.
LimitPaginationException
  This exception is thrown when a limit is provided in a paginated query using the Pagination class
NotFoundException
  Thrown when a resource is not found
OffsetPaginationException
  This exception is thrown when an offset is passed in a paginated query using the Pagination class
ResourceNotFoundException
  This exception is thrown when a service requested is not found.
RestParseException
  This exception is thrown when an error occurs during REST parsing.
RestPHPException
  This exception is thrown when an error occurs during REST parsing.
UserUnauthenticatedException
  This exception is thrown when one tries to access a protected resource without being authenticated
UserUnauthorizedException
  This exception is thrown when a user is not authorized to access a resource
PostSwitchRunEvent
  Event runs after the switch runs, you can access the response from this event
PreKernelBootEvent
  Event fired before the kernel boots
WebKernel
Request
  This method extends the Symfony request class to add more functionality to the request object.
BaseResponse
  This provides a uniform response format for our entire application.
Response
  This is the internal response. It should not be used anywhere in the project but in the core framework
BaseRoutes
  This is the base routes class, it extends the Symfony route collection class and is used to define routes in the framework
PioniaRouter
  This is the basis for defining routes in the application.
SupportedHttpMethods
  This class holds the supported http methods in the framework.
RetrieveCreateUpdateService
  Adds retrieve, create and update actions to the service.
RetrieveListCreateService
  Adds the retrieve and create actions to the service.
RetrieveListCreateUpdateDeleteService
  Adds the retrieve, create and update actions to the service.
RetrieveListDeleteService
  Adds the delete and retrieve actions to the service.
RetrieveListRandomService
  Adds the retrieve and create actions to the service.
RetrieveListUpdateDeleteService
  Adds the retrieve, update and delete actions to the service.
RetrieveListUpdateService
  Adds the retrieve and update actions to the service.
UniversalGenericService
  Adds the retrieve/details, create, list, update, random and delete actions to the service.
GenericService
  Base Service for generic services
Service
  Base Service for generic services
BaseApiServiceSwitch
  This is the base class for the API service switch. It is used to switch between different services based on the request data.
PioniaLogger
Middleware
MiddlewareChain
ContractBuilder
Piql
  Pionia Query Builder Provides base-strategy to perform all database queries in all RDBMS
Porm
Raw
  The Medoo raw object.
Agg
  Aggregate functions for the PORM library.
Builder
Join
  Builds relationships across multiple tables.
Where
Db
  Provides a basis for other query builders to base on.
Connection
BaseDatabaseException
  This is the base exception class that all other exceptions must extend.
InvalidWhereClause
  This is the base exception class that all other exceptions must extend.
PaginationCore
TemplateEngine
AuthenticationBackendMock
  Base class for other Authentication backend to inherit.
MiddlewareMock
MiddlewareMock2
PioniaTestCase
Support
Validator
  This class is used to validate data
ArrayableTest
AuthenticationBackendChainTest
MiddlewareChainTest
DatabaseConnectionTest

#### Traits

BuiltInServices
Cacheable
  Add caching capabilities to any class.
CallsCommands
HasParameters
InteractsWithIO
AuthTrait
  This trait provides common authentication methods for the services
CrudContract
EventsContract
JoinContract
UploadsContract
CreateMixin
  This mixin adds the create functionality to the service.
DeleteMixin
  This mixin adds the delete functionality to the service.
ListMixin
  This mixin adds the list functionality to the service.
RandomMixin
  This mixin adds the random functionality to the service.
RetrieveMixin
  This mixin adds the retrieve method to the class that uses it.
UpdateMixin
  This mixin adds the update functionality to the service.
RequestActionTrait
  Provides helper methods for request actions
MiddlewareTrait
AggregateTrait
FilterTrait
JoinParseTrait
ParseTrait
TableLevelQueryTrait
HelperMocksTrait
AppDatabaseHelper
AppHelpersTrait
ApplicationLifecycleHooks
CachedEndpoints
  Checks and returns cached moonlight endpoints.
Conditionable
Containable
Dumpable
InteractsWithTime
Microable
PathsTrait
ValidationTrait

#### Enums

NAMESPACES
DIRECTORIES
JoinType
  Supported join types in Pionia
PioniaApplicationType

#### Constants

BASEPATH = \dirname(__DIR__, 1)
BASEPATH = \dirname(__DIR__, 1)
BASEPATH = $applicationPath
BASEPATH = dirname(__DIR__, 2)
PIONIA_BINARY = 'pionia'
PIONIA_START = \microtime(\true)
PIONIA_START = \microtime(\true)

#### Functions

allBuiltins() : Arrayable
tap() : HighOrderTapProxy|TValue
  Call the given Closure with the given value then return the value.
arr() : Arrayable
  Get an item from an array using "dot" notation.
env() : mixed
  Get an item from the environment. Or default if it does not exist.
setEnv() : void
  Adds a temporary key-value to the environment.
response() : BaseResponse
  Helper function to return a response
app() : PioniaApplication
  Helper function to return the application instance
container() : Container
  Helper function to return the application container
db() : Porm|null
  Run any pionia-powered queries
table() : Porm
  Run any pionia-powered queries
alias() : mixed
directoryFor() : mixed
  Get any directory from the application container
yesNo() : string
  This function returns a yes or no phrase based on the condition
asBool() : array<string|int, mixed>
  convert a value to a boolean
writeIniFile() : bool
  Write an ini configuration file This writes to the file in a lock-safe manner
logger() : LoggerInterface
  Get the logger instance from the application container
addIniSection() : bool
  This function adds a new section to an ini file We generally use this to generate and add new sections to the generated.ini file which holds settings for the auto-generated files
cachedResponse() : BaseResponse
  This function caches a response if the service has caching enabled.
recached() : BaseResponse
  Acronym for `cachedResponse` function but with more readable arguments
render() : void
  Render a template file from the templates folder.
parseHtml() : array<string|int, mixed>
  Get all the builtins
asset() : string|null
  Get the asset path
blank() : bool
  Determine if the given value is "blank".
validate() : Validator
  Validate data
toCamelCase() : string
  Convert a string to camel case
toSnakeCase() : string
  Convert a string to snake case
classify() : string
  Convert a string to a class name like format
arrayToString() : string
  Convert an array to a string
slugify() : string
  Convert a string to a slug-like format
singularize() : string
  Convert a string to a singular form
pluralize() : string
  Convert a string to a plural form
capitalize() : string
  Capitalize a string
jsonify() : string
  Convert anything to a json string
flatten() : array<string|int, mixed>
  Flatten an array
is_cached_in() : bool

### Constants

#### BASEPATH

application.php : 58
`public mixed BASEPATH = \dirname(__DIR__, 1)`

#### BASEPATH

index.php : 3
`public mixed BASEPATH = \dirname(__DIR__, 1)`

#### BASEPATH

PioniaApplication.php : 151
`public mixed BASEPATH = $applicationPath`

#### BASEPATH

helpers.php : 117
`public mixed BASEPATH = dirname(__DIR__, 2)`

#### PIONIA_BINARY

PioniaApplication.php : 745
`public mixed PIONIA_BINARY = 'pionia'`

#### PIONIA_START

application.php : 49
`public mixed PIONIA_START = \microtime(\true)`

#### PIONIA_START

index.php : 7
`public mixed PIONIA_START = \microtime(\true)`

### Functions

#### allBuiltins()

All.php : 48
`allBuiltins() : Arrayable`

##### Return values

Arrayable

#### tap()

helpers.php : 33

Call the given Closure with the given value then return the value.

`tap(TValue $value[, callable(TValue): mixed|null $callback = null ]) : HighOrderTapProxy|TValue`

Value returned is not transformed by the closure.

##### Parameters

$value : TValue
$callback : callable(TValue): mixed|null = null

##### Tags

template

  TValue

##### Return values

HighOrderTapProxy|TValue

#### arr()

helpers.php : 52

Get an item from an array using "dot" notation.

`arr(array<string|int, mixed>|null $array) : Arrayable`

##### Parameters

$array : array<string|int, mixed>|null

##### Return values

Arrayable

#### env()

helpers.php : 64

Get an item from the environment. Or default if it does not exist.

`env([string|null $key = null ][, mixed $default = null ]) : mixed`

If both the key and the default value are null, the function should return the entire environment.

##### Parameters

$key : string|null = null
$default : mixed = null

#### setEnv()

helpers.php : 76

Adds a temporary key-value to the environment.

`setEnv(string $key, mixed $value) : void`

This can only be retrieved using the `env` function.

##### Parameters

$key : string
$value : mixed

#### response()

helpers.php : 98

Helper function to return a response

`response([ $returnCode = 0 ][, string|null $returnMessage = null ][, mixed $returnData = null ][, mixed $extraData = null ]) : BaseResponse`

##### Parameters

$returnCode : = 0

  int

$returnMessage : string|null = null
$returnData : mixed = null
$extraData : mixed = null

##### Return values

BaseResponse

#### app()

helpers.php : 109

Helper function to return the application instance

`app() : PioniaApplication`

##### Return values

PioniaApplication

#### container()

helpers.php : 128

Helper function to return the application container

`container() : Container`

##### Return values

Container

#### db()

helpers.php : 143

Run any pionia-powered queries

`db(string $tableName[, string|null $tableAlias = null ][, string|null $using = null ]) : Porm|null`

##### Parameters

$tableName : string

  The name of the table to connect to

$tableAlias : string|null = null
$using : string|null = null

##### Tags

throws
  Exception

##### Return values

Porm|null

#### table()

helpers.php : 163

Run any pionia-powered queries

`table(string $tableName[, string|null $tableAlias = null ][, string|null $using = null ]) : Porm`

##### Parameters

$tableName : string

  The name of the table to connect to

$tableAlias : string|null = null

  The alias to use for the table provided

$using : string|null = null

  The connection to use

##### Tags

throws
  Exception
example

      table('users')->where(['username' => 'Pionia'])->get();

##### Return values

Porm —

The porm instance for further chaining of queries

#### alias()

helpers.php : 175
`alias(mixed $key) : mixed`

##### Parameters

$key : mixed

#### directoryFor()

helpers.php : 185

Get any directory from the application container

`directoryFor(mixed $key) : mixed`

##### Parameters

$key : mixed

#### yesNo()

helpers.php : 200

This function returns a yes or no phrase based on the condition

`yesNo(bool $condition[, string|null $yesPhrase = 'Yes' ][, string|null $noPhrase = 'No' ]) : string`

##### Parameters

$condition : bool

  The condition to check

$yesPhrase : string|null = 'Yes'

  The phrase to return if the condition is true

$noPhrase : string|null = 'No'

  The phrase to return if the condition is false

##### Return values

string

#### asBool()

helpers.php : 211

convert a value to a boolean

`asBool(mixed $value) : array<string|int, mixed>`

##### Parameters

$value : mixed

##### Return values

array<string|int, mixed>

#### writeIniFile()

helpers.php : 226

Write an ini configuration file This writes to the file in a lock-safe manner

`writeIniFile(string $file[, array<string|int, mixed> $array = [] ]) : bool`

##### Parameters

$file : string
$array : array<string|int, mixed> = []

##### Return values

bool

#### logger()

helpers.php : 292

Get the logger instance from the application container

`logger() : LoggerInterface`

##### Return values

LoggerInterface

#### addIniSection()

helpers.php : 313

This function adds a new section to an ini file We generally use this to generate and add new sections to the generated.ini file which holds settings for the auto-generated files

`addIniSection(string $section[, array<string|int, mixed>|null $keyValueToAppend = [] ][, string $iniFile = 'generated.ini' ]) : bool`

This function will create the file if it does not exist, add the section if it does not exist or update the section if it exists

##### Parameters

$section : string
$keyValueToAppend : array<string|int, mixed>|null = []
$iniFile : string = 'generated.ini'

##### Return values

bool

#### cachedResponse()

helpers.php : 345

This function caches a response if the service has caching enabled.

`cachedResponse(Service $instance, BaseResponse $response[, mixed $ttl = 60 ]) : BaseResponse`

Cached key is of the format `service_action` in camel case. If no ttl is defined, caching will happen for only 60 seconds

##### Parameters

$instance : Service

  The service we are currently in, just pass `this` here!

$response : BaseResponse

  The response object to cache, you can use `response()` for this!

$ttl : mixed = 60

  The time to live for the cache, defaults to 60 seconds

##### Tags

note

  This function is only available if the service has caching enabled

note

  This is still under rigorous tests

##### Return values

BaseResponse —

The cached response / the response you passed. It's not tampered with

#### recached()

helpers.php : 376

Acronym for `cachedResponse` function but with more readable arguments

`recached(Service $instance[, int|null $returnCode = 0 ][, string|null $returnMessage = null ][, mixed|null $returnData = null ][, mixed|null $extraData = null ][, mixed $ttl = 60 ]) : BaseResponse`

##### Parameters

$instance : Service

  The service we are currently in, just pass `this` here

$returnCode : int|null = 0

  The return code for the response, defaults to 0

$returnMessage : string|null = null

  The return message for the response, defaults to null

$returnData : mixed|null = null

  The return data for the response, defaults to null

$extraData : mixed|null = null

  The extra data for the response, defaults to null

$ttl : mixed = 60

  The time to live for the cache, defaults to 60 seconds

##### Tags

note

  This function is only useful if the service has caching enabled

##### Return values

BaseResponse —

The cached response / the response you passed. It's not tampered with

#### render()

helpers.php : 420

Render a template file from the templates folder.

`render( $file[, array<string|int, mixed>|null $data = [] ]) : void`

##### Parameters

$file :
$data : array<string|int, mixed>|null = []

#### parseHtml()

helpers.php : 435

Get all the builtins

`parseHtml( $file[, array<string|int, mixed>|null $data = [] ]) : array<string|int, mixed>`

##### Parameters

$file :
$data : array<string|int, mixed>|null = []

##### Return values

array<string|int, mixed>

#### asset()

helpers.php : 448

Get the asset path

`asset( $file[, string|null $dir = null ]) : string|null`

##### Parameters

$file :
$dir : string|null = null

##### Return values

string|null

#### blank()

helpers.php : 474

Determine if the given value is "blank".

`blank(mixed $value) : bool`

##### Parameters

$value : mixed

##### Tags

phpstan-assert-if-false

  !=null|'' $value

phpstan-assert-if-true

  !=numeric|bool $value

##### Return values

bool

#### validate()

helpers.php : 511

Validate data

`validate(string $field, Arrayable|Request|Service $data) : Validator`

##### Parameters

$field : string
$data : Arrayable|Request|Service

##### Return values

Validator

#### toCamelCase()

helpers.php : 526

Convert a string to camel case

`toCamelCase(string $value) : string`

##### Parameters

$value : string

##### Return values

string

#### toSnakeCase()

helpers.php : 536

Convert a string to snake case

`toSnakeCase(string $value) : string`

##### Parameters

$value : string

##### Return values

string

#### classify()

helpers.php : 546

Convert a string to a class name like format

`classify(string $value) : string`

##### Parameters

$value : string

##### Return values

string

#### arrayToString()

helpers.php : 556

Convert an array to a string

`arrayToString(array<string|int, mixed> $value[, string|null $separator = ',' ]) : string`

##### Parameters

$value : array<string|int, mixed>
$separator : string|null = ','

##### Return values

string

#### slugify()

helpers.php : 566

Convert a string to a slug-like format

`slugify(string $value) : string`

##### Parameters

$value : string

##### Return values

string

#### singularize()

helpers.php : 576

Convert a string to a singular form

`singularize(string $word) : string`

##### Parameters

$word : string

##### Return values

string

#### pluralize()

helpers.php : 586

Convert a string to a plural form

`pluralize(string $word) : string`

##### Parameters

$word : string

##### Return values

string

#### capitalize()

helpers.php : 596

Capitalize a string

`capitalize(string $phrase) : string`

##### Parameters

$phrase : string

##### Return values

string

#### jsonify()

helpers.php : 606

Convert anything to a json string

`jsonify(mixed $phrase) : string`

##### Parameters

$phrase : mixed

##### Return values

string

#### flatten()

helpers.php : 619

Flatten an array

`flatten(array<string|int, mixed> $flatten) : array<string|int, mixed>`

##### Parameters

$flatten : array<string|int, mixed>

##### Tags

example

  flatten(['a', 'b', ['c', 'd']]) => ['a', 'b', 'c', 'd']

##### Return values

array<string|int, mixed>

#### is_cached_in()

helpers.php : 627
`is_cached_in(mixed $keyCached, mixed $keyToCheck) : bool`

##### Parameters

$keyCached : mixed
$keyToCheck : mixed

##### Return values

bool

## Search results