Skip to content

Phalcon contracts

NOTE

All classes are prefixed with Phalcon

Contracts\Assets\Asset

Interface Source on GitHub

Canonical contract for Phalcon\Assets\Asset.

Covers collection membership: an asset's key, type, HTML attributes, and filter flag. The file-output pipeline (Phalcon\Assets\Manager::output()) requires the concrete Phalcon\Assets\Asset class.

Method Summary

Methods

Public · 7

getAssetKey()

public function getAssetKey(): string;

Gets the asset's key.

getAttributes()

public function getAttributes(): array|null;

Gets extra HTML attributes.

getFilter()

public function getFilter(): bool;

Gets if the asset must be filtered or not.

getType()

public function getType(): string;

Gets the asset's type.

setAttributes()

public function setAttributes( array $attributes ): Asset;

Sets extra HTML attributes.

setFilter()

public function setFilter( bool $filter ): Asset;

Sets if the asset must be filtered or not.

setType()

public function setType( string $type ): Asset;

Sets the asset's type.

Contracts\Assets\Filter

Interface Source on GitHub

Canonical contract for Phalcon\Assets filters (Cssmin, Jsmin, None, and custom user filters).

Method Summary

Methods

Public · 1

filter()

public function filter( string $content ): string;

Filters the content returning a string with the filtered content

Contracts\Auth\Access\Access

Interface Source on GitHub

Access gates are Specifications: policies that decide whether the current identity may run the given action. The enforcement point passes the identity (the guard) and the request context on every call; gates hold no reference to the auth manager.

  • Phalcon\Contracts\Auth\Access\Access

Uses Phalcon\Contracts\Auth\Guard\Guard

Method Summary

Methods

Public · 6

getExceptActions()

public function getExceptActions(): array;

getOnlyActions()

public function getOnlyActions(): array;

isAllowed()

public function isAllowed(
    Guard $guard,
    string $actionName,
    array $context = []
): bool;

Whether the identity behind the guard may run the action.

redirectTo()

public function redirectTo(): array|null;

setExceptActions()

public function setExceptActions( array $exceptActions = [] ): void;

Exempts the listed action names from the gate; every other action is checked. See setOnlyActions() for the gate-family divergence note.

setOnlyActions()

public function setOnlyActions( array $onlyActions = [] ): void;

Restricts the gate to the listed action names.

Authoritative semantics: the gate applies only to the listed actions; an action that is not listed passes without a check (and except() is the inverse - the gate applies to every action except those listed).

NOTE: the implementations currently diverge. The Acl gate follows the authoritative semantics above, while the binary gates (Auth, Guest) treat only as a whitelist - an unlisted action is denied even when the base condition holds. The two gate families will be aligned in the next major version; until then, choose the gate family deliberately, because for an unlisted action they return opposite answers to the same call.

Contracts\Auth\Adapter\Adapter

Interface Source on GitHub

Authentication adapter contract.

Adapters look users up by credentials or by identifier and verify the password against the stored hash. The credential payload is intentionally unsealed: any user-row field may be used as the lookup key, plus an optional password entry that is ignored during the row match and consumed only by validateCredentials().

Uses Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Encryption\Security\Security

Method Summary

Methods

Public · 4

fromOptions()

public static function fromOptions(
    Security $hasher,
    array $options
): static;

Build an adapter from a flat options map. Used by ManagerFactory to wire adapters from the application config; each implementation is free to interpret the option keys it cares about.

retrieveByCredentials()

public function retrieveByCredentials( array $credentials ): AuthUser|null;

Find a user matching the given credentials (e.g. ['email' => 'a@b']). The 'password' key, if present, is ignored during the lookup. Returns null if no user matches.

retrieveById()

public function retrieveById( mixed $id ): AuthUser|null;

Find a user by their unique identifier.

validateCredentials()

public function validateCredentials(
    AuthUser $user,
    array $credentials
): bool;

Validate the provided credentials against the given user. Implementations typically verify the password hash held under the 'password' key.

Contracts\Auth\Adapter\AdapterConfig

Interface Source on GitHub

Authentication adapter configuration contract.

Per-adapter config shape is intentionally adapter-specific (e.g. Stream exposes getFile(), Memory exposes getUsers()); the only field shared across all adapters is the optional model class used during user hydration.

  • Phalcon\Contracts\Auth\Adapter\AdapterConfig

Method Summary

Methods

Public · 1

getModel()

public function getModel(): string|null;

Returns the user-model class name to hydrate, if configured.

Contracts\Auth\Adapter\RememberAdapter

Interface Source on GitHub

Capability extension implemented by adapters that support remember-me.

Uses Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Auth\RememberToken

Method Summary

Methods

Public · 2

createRememberToken()

public function createRememberToken( AuthUser $user ): RememberToken;

Create and persist a new remember token for the user.

retrieveByToken()

public function retrieveByToken(
    mixed $id,
    string $token,
    string $userAgent = null
): AuthUser|null;

Retrieve a user by the remember-me cookie payload.

Contracts\Auth\AuthRemember

Interface Source on GitHub

Implemented by authenticatable models that support remember-me tokens. This is intentionally separate from AuthUser so that adapters which do not support remember-me are not forced to implement it.

  • Phalcon\Contracts\Auth\AuthRemember

Method Summary

Methods

Public · 2

createRememberToken()

public function createRememberToken(
    string $token,
    string $userAgent = null
): RememberToken;

Persists a new remember token for the user.

getRememberToken()

public function getRememberToken( string $token ): RememberToken|null;

Returns the remember token entry matching the given token value, or null if not found.

Contracts\Auth\AuthUser

Interface Source on GitHub

Implemented by user models that can be authenticated.

  • Phalcon\Contracts\Auth\AuthUser

Method Summary

Methods

Public · 2

getAuthIdentifier()

public function getAuthIdentifier(): int|string;

Returns the unique identifier for the authenticatable user (e.g. the primary key). Implementations MUST return a non-null scalar; if a record cannot produce one, the implementation should fail at construction time rather than returning null.

getAuthPassword()

public function getAuthPassword(): string;

Returns the hashed password for the authenticatable user.

Contracts\Auth\Guard\BasicAuth

Interface Source on GitHub

  • Phalcon\Contracts\Auth\Guard\BasicAuth

Uses Phalcon\Contracts\Auth\AuthUser

Method Summary

Methods

Public · 2

basic()

public function basic(
    string $field = "email",
    array $extraConditions = []
): bool;

Authenticate against HTTP Basic credentials. Returns true on success.

onceBasic()

public function onceBasic(
    string $field = "email",
    array $extraConditions = []
): false|AuthUser;

Like basic() but does not persist; returns the resolved user on success or false on failure.

Contracts\Auth\Guard\Guard

Interface Source on GitHub

  • Phalcon\Contracts\Auth\Guard\Guard

Uses Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\AuthUser · Phalcon\Contracts\Container\Service\Collection · Phalcon\Di\DiInterface

Method Summary

Methods

Public · 9

check()

public function check(): bool;

Whether the current request is authenticated.

fromOptions()

public static function fromOptions(
    Adapter $adapter,
    mixed $container,
    array $options
): static;

Build a guard from an adapter, the application container, and a flat options map. Used by ManagerFactory to wire guards from the application config; each implementation resolves the framework services it needs from the container.

The container is Container-first: pass a Phalcon\Container\Container. The legacy Phalcon\Di\Di is also supported with provisions - its service definitions must be pre-registered (no autowiring).

getLastUserAttempted()

public function getLastUserAttempted(): AuthUser|null;

Returns the last user the guard tried to authenticate during this request, regardless of success.

guest()

public function guest(): bool;

Whether the current request is unauthenticated.

hasUser()

public function hasUser(): bool;

Whether the guard currently holds a resolved user.

id()

public function id(): int|string|null;

Returns the authenticated user's identifier, or null when no authenticated user is present.

setUser()

public function setUser( AuthUser $user ): static;

Sets the current user explicitly. Returns $this for fluent chaining.

user()

public function user(): AuthUser|null;

Returns the resolved user for the current request, or null.

validate()

public function validate( array $credentials = [] ): bool;

Validates the given credentials without logging in.

Contracts\Auth\Guard\GuardConfig

Interface Source on GitHub

Authentication guard configuration contract.

Per-guard config shape is intentionally guard-specific (e.g. Token exposes getInputKey()/getStorageKey(); Session has no required config today). The contract carries no methods of its own - it only marks the type so AbstractGuard can accept any guard config uniformly.

  • Phalcon\Contracts\Auth\Guard\GuardConfig

Contracts\Auth\Guard\GuardStateful

Interface Source on GitHub

Implemented by guards backed by persistent state (sessions/cookies).

  • Phalcon\Contracts\Auth\Guard\GuardStateful

Uses Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\AuthUser

Method Summary

Methods

Public · 5

attempt()

public function attempt(
    array $credentials = [],
    bool $remember = false
): bool;

Attempts to authenticate the user with the given credentials and, on success, persists the resulting state on the guard.

login()

public function login(
    AuthUser $user,
    bool $remember = false
): void;

loginById()

public function loginById(
    mixed $id,
    bool $remember = false
): false|AuthUser;

Logs in the user identified by $id. Returns the resolved user on success or false when no user matches the id.

logout()

public function logout(): void;

viaRemember()

public function viaRemember(): bool;

Contracts\Auth\Manager

Interface Source on GitHub

  • Phalcon\Contracts\Auth\Manager

Uses Phalcon\Auth\Exception · Phalcon\Contracts\Auth\Access\Access · Phalcon\Contracts\Auth\Adapter\Adapter · Phalcon\Contracts\Auth\Guard\Guard

Method Summary

Methods

Public · 18

access()

public function access( string $accessName ): self;

Activates the named access gate for the current request and returns the manager for fluent only()/except() configuration.

Enforcement is opt-in and fail-open: when no access has been activated (getAccess() returns null) every dispatch is allowed. An activated gate stays active for subsequent dispatches in the same request (forwards, nested handlers) until it is replaced. Under classic FPM this is scoped to a single request; long-running runtimes must reset it per request.

addAccessList()

public function addAccessList( array $accessList ): self;

addGuard()

public function addGuard(
    string $nameGuard,
    Guard $guard,
    bool $isDefault = false
): self;

attempt()

public function attempt(
    array $credentials = [],
    bool $remember = false
): bool;

check()

public function check(): bool;

Whether the default guard reports the current request as authenticated.

except()

public function except( string $actions ): self;

Restricts the active access gate to skip the listed action names.

getAccess()

public function getAccess(): Access|null;

Returns the active access gate, or null when none has been activated - in which case listener enforcement is a no-op (see access()).

getAccessList()

public function getAccessList(): array;

getDefaultGuard()

public function getDefaultGuard(): Guard|null;

getGuards()

public function getGuards(): array;

guard()

public function guard( string $name = null ): Guard;

Returns the named guard, or the default guard when $name is null.

id()

public function id(): int|string|null;

Returns the authenticated user's identifier from the default guard, or null when no authenticated user is present.

logout()

public function logout(): void;

Logs the current user out via the default guard.

only()

public function only( string $actions ): self;

Restricts the active access gate to apply only to the listed action names.

setAccess()

public function setAccess( Access $access ): self;

setDefaultGuard()

public function setDefaultGuard( Guard $guard ): self;

user()

public function user(): AuthUser|null;

Returns the resolved user from the default guard, or null.

validate()

public function validate( array $credentials = [] ): bool;

Validates the given credentials against the default guard without logging in.

Contracts\Auth\RememberToken

Interface Source on GitHub

A persisted remember-me token row.

  • Phalcon\Contracts\Auth\RememberToken

Method Summary

Methods

Public · 3

delete()

public function delete(): bool;

Deletes the token from storage.

getToken()

public function getToken(): string;

Returns the token value stored for this remember entry.

getUserAgent()

public function getUserAgent(): string|null;

Returns the user agent associated with this token, if any.

Contracts\Cache\Cache

Interface Source on GitHub

Canonical contract for Phalcon\Cache\Cache.

Uses DateInterval · Phalcon\Cache\Exception\InvalidArgumentException

Method Summary

Methods

Public · 8

clear()

public function clear(): bool;

Wipes clean the entire cache's keys.

delete()

public function delete( string $key ): bool;

Delete an item from the cache by its unique key.

deleteMultiple()

public function deleteMultiple( mixed $keys ): bool;

Deletes multiple cache items in a single operation.

get()

public function get(
    string $key,
    mixed $defaultValue = null
);

Fetches a value from the cache.

getMultiple()

public function getMultiple(
    mixed $keys,
    mixed $defaultValue = null
);

Obtains multiple cache items by their unique keys.

has()

public function has( string $key ): bool;

Determines whether an item is present in the cache.

set()

public function set(
    string $key,
    mixed $value,
    mixed $ttl = null
): bool;

Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.

setMultiple()

public function setMultiple(
    mixed $values,
    mixed $ttl = null
): bool;

Persists a set of key => value pairs in the cache, with an optional TTL.

Contracts\Cli\Dispatcher

Interface Source on GitHub

Canonical contract for Phalcon\Cli\Dispatcher.

Uses Phalcon\Cli\TaskInterface · Phalcon\Contracts\Dispatcher\Dispatcher

Method Summary

Methods

Public · 9

getActiveTask()

public function getActiveTask(): TaskInterface;

Returns the active task in the dispatcher

getLastTask()

public function getLastTask(): TaskInterface;

Returns the latest dispatched controller

getOptions()

public function getOptions(): array;

Get dispatched options

getTaskName()

public function getTaskName(): string;

Gets last dispatched task name

getTaskSuffix()

public function getTaskSuffix(): string;

Gets default task suffix

setDefaultTask()

public function setDefaultTask( string $taskName ): void;

Sets the default task name

setOptions()

public function setOptions( array $options ): void;

Set the options to be dispatched

setTaskName()

public function setTaskName( string $taskName ): void;

Sets the task name to be dispatched

setTaskSuffix()

public function setTaskSuffix( string $taskSuffix ): void;

Sets the default task suffix

Contracts\Container\Ioc\IocContainer

Interface Source on GitHub

[IocContainer][] affords obtaining services by name.

  • Notes:

    • This interface does not afford service management. The container will need to obtain services somehow, e.g. from a [Service-Interop][] implementation.

Method Summary

Methods

Public · 2

getService()

public function getService( string $serviceName ): object;

Returns an instance of the $serviceName.

  • Directives:

    • Implementations MUST throw [IocThrowable][] if the container cannot return an instance of the $serviceName.
  • Notes:

    • The logic for this method is expressly unspecified. Retrieval may be accomplished via a service management subsystem, or by some other means.

    • The returned instance may be new or shared. The retrieval logic defines the service lifetime, not the container (per se) and not the caller requesting the service.

hasService()

public function hasService( string $serviceName ): bool;

Is the container able to return an instance of the $serviceName?

  • Notes:

    • The logic for this method is expressly unspecified. The ability check may be accomplished by querying a service management subsystem, or by some other means.

Contracts\Container\Ioc\IocContainerFactory

Interface Source on GitHub

[IocContainerFactory][] affords obtaining a new instance of [IocContainer][].

  • Phalcon\Contracts\Container\Ioc\IocContainerFactory

Method Summary

Methods

Public · 1

newContainer()

public function newContainer(): IocContainer;

Returns a new instance of [IocContainer][].

  • Notes:

    • Container instantiation logic is not specified. Implementations might use providers, configuration files, attribute or annotation collection, or some other means to create and populate a container. Implementations might also choose to return a compiled or otherwise reconstituted container.

Contracts\Container\Ioc\IocThrowable

Interface Source on GitHub

[IocThrowable][] extends [Throwable][] to mark an [Exception][] as IOC-related.

It adds no class members.

Uses Throwable

Contracts\Container\Ioc\IocTypeAliases

Interface Source on GitHub

  • Phalcon\Contracts\Container\Ioc\IocTypeAliases

Contracts\Container\Resolver\ReflectionMethodResolver

Interface Source on GitHub

  • Phalcon\Contracts\Container\Resolver\ReflectionMethodResolver

Uses Phalcon\Contracts\Container\Ioc\IocContainer · ReflectionMethod

Method Summary

Methods

Public · 1

resolveMethod()

public function resolveMethod(
    IocContainer $ioc,
    ReflectionMethod $method,
    object $instance
): void;

Contracts\Container\Resolver\ReflectionParameterResolver

Interface Source on GitHub

Uses Phalcon\Contracts\Container\Ioc\IocContainer · ReflectionParameter

Method Summary

Methods

Public · 1

resolveParameter()

public function resolveParameter(
    IocContainer $ioc,
    ReflectionParameter $parameter
): mixed;

Contracts\Container\Resolver\Resolvable

Interface Source on GitHub

  • Phalcon\Contracts\Container\Resolver\Resolvable

Uses Phalcon\Contracts\Container\Ioc\IocContainer

Method Summary

Methods

Public · 1

resolve()

public function resolve( IocContainer $ioc ): mixed;

Contracts\Container\Resolver\ResolverService

Interface Source on GitHub

Uses Phalcon\Contracts\Container\Ioc\IocContainer · ReflectionMethod · ReflectionParameter · ReflectionType

Method Summary

Methods

Public · 6

isResolvableClass()

public function isResolvableClass( string $className ): bool;

resolveCall()

public function resolveCall(
    IocContainer $ioc,
    callable $callableObject,
    array $arguments
): mixed;

resolveClass()

public function resolveClass(
    IocContainer $ioc,
    string $className,
    array $arguments
): object;

resolveMethod()

public function resolveMethod(
    IocContainer $ioc,
    ReflectionMethod $method,
    object $instance
): void;

resolveParameters()

public function resolveParameters(
    IocContainer $ioc,
    array $parameters,
    array $arguments
): array;

resolveType()

public function resolveType(
    IocContainer $ioc,
    ReflectionType $type
): mixed;

Contracts\Container\Resolver\ResolverThrowable

Interface Source on GitHub

  • Throwable
    • Phalcon\Contracts\Container\Resolver\ResolverThrowable

Uses Throwable

Contracts\Container\Service\Collection

Interface Source on GitHub

Uses Closure · Phalcon\Container\Definition\ServiceDefinition · Phalcon\Container\Resolver\Resolver · Phalcon\Contracts\Container\Ioc\IocContainer

Method Summary

Methods

Public · 30

bind()

public function bind(
    string $interfaceName,
    string $concrete
): ServiceDefinition;

callableGet()

public function callableGet( string $name ): Closure;

callableNew()

public function callableNew( string $name ): Closure;

extend()

public function extend(
    string $name,
    callable $callableObject
): void;

get()

public function get( string $name ): mixed;

getAlias()

public function getAlias( string $name ): string;

getByTag()

public function getByTag( string $tag ): array;

getDefinition()

public function getDefinition( string $name ): ServiceDefinition;

getInstance()

public function getInstance( string $name ): object;

getParameter()

public function getParameter( string $name ): mixed;

getResolver()

public function getResolver(): Resolver;

has()

public function has( string $name ): bool;

hasAlias()

public function hasAlias( string $name ): bool;

hasDefinition()

public function hasDefinition( string $name ): bool;

hasInstance()

public function hasInstance( string $name ): bool;

hasParameter()

public function hasParameter( string $name ): bool;

isAutowireEnabled()

public function isAutowireEnabled(): bool;

new()

public function new( string $name ): mixed;

newDefinition()

public function newDefinition( string $name ): ServiceDefinition;

set()

public function set(
    string $name,
    mixed $definition
): ServiceDefinition;

setAlias()

public function setAlias(
    string $name,
    string $alias
): static;

setAutowire()

public function setAutowire( bool $enabled ): static;

setDefinition()

public function setDefinition(
    string $name,
    ServiceDefinition $definition
): static;

setInstance()

public function setInstance(
    string $name,
    object $instance,
    string $lifetime
): static;

setParameter()

public function setParameter(
    string $name,
    mixed $value
): static;

unsetAlias()

public function unsetAlias( string $name ): void;

unsetDefinition()

public function unsetDefinition( string $name ): void;

unsetInstance()

public function unsetInstance( string $name ): void;

unsetInstances()

public function unsetInstances( string $lifetime ): void;

unsetParameter()

public function unsetParameter( string $name ): void;

Contracts\Container\Service\Definition

Interface Source on GitHub

  • Phalcon\Contracts\Container\Service\Definition

Uses Phalcon\Contracts\Container\Ioc\IocContainer

Method Summary

Methods

Public · 17

addExtender()

public function addExtender( callable $extender ): static;

buildService()

public function buildService( IocContainer $ioc ): object;

getClass()

public function getClass(): string;

getExtenders()

public function getExtenders(): array;

getFactory()

public function getFactory(): callable;

getLifetime()

public function getLifetime(): string;

getServiceName()

public function getServiceName(): string;

hasClass()

public function hasClass(): bool;

hasExtenders()

public function hasExtenders(): bool;

hasFactory()

public function hasFactory(): bool;

setClass()

public function setClass( string $className ): static;

setExtenders()

public function setExtenders( array $extenders ): static;

setFactory()

public function setFactory( callable $factory ): static;

setLifetime()

public function setLifetime( string $lifetime ): static;

unsetClass()

public function unsetClass(): static;

unsetExtenders()

public function unsetExtenders(): static;

unsetFactory()

public function unsetFactory(): static;

Contracts\Container\Service\Provider

Interface Source on GitHub

  • Phalcon\Contracts\Container\Service\Provider

Method Summary

Methods

Public · 1

provide()

public function provide( Collection $services ): void;

Contracts\Container\Service\Throwable

Interface Source on GitHub

  • PhpThrowable
    • Phalcon\Contracts\Container\Service\Throwable

Uses Throwable

Contracts\Db\Adapter\Adapter

Interface Source on GitHub

Canonical contract for Phalcon\Db adapters.

@todo v7 - these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - addCheck() : bool - createMaterializedView() : bool - dropCheck() : bool - dropMaterializedView() : bool - onConflictUpdate() : string - refreshMaterializedView() : bool - returning() : string

Uses Phalcon\Db\ColumnInterface · Phalcon\Db\DialectInterface · Phalcon\Db\IndexInterface · Phalcon\Db\RawValue · Phalcon\Db\ReferenceInterface · Phalcon\Db\ResultInterface

Method Summary

public bool addColumn(string $tableName,string $schemaName,ColumnInterface $column) Adds a column to a table public bool addForeignKey(string $tableName,string $schemaName,ReferenceInterface $reference) Adds a foreign key to a table public bool addIndex(string $tableName,string $schemaName,IndexInterface $index) Adds an index to a table public bool addPrimaryKey(string $tableName,string $schemaName,IndexInterface $index) Adds a primary key to a table public int affectedRows() Returns the number of affected rows by the last INSERT/UPDATE/DELETE public bool begin( bool $nesting = true ) Starts a transaction in the connection public void close() Closes active connection returning success. Phalcon automatically closes public bool commit( bool $nesting = true ) Commits the active transaction in the connection public void connect( array $descriptor = [] ) This method is automatically called in \Phalcon\Db\Adapter\Pdo public bool createSavepoint( string $name ) Creates a new savepoint public bool createTable(string $tableName,string $schemaName,array $definition) Creates a table public bool createView(string $viewName,array $definition,string $schemaName = null) Creates a view public bool delete(mixed $table,string $whereCondition = null,array $placeholders = [],array $dataTypes = []) Deletes data from a table using custom RDBMS SQL syntax public ColumnInterface[] describeColumns(string $table,string $schema = null) Returns an array of Phalcon\Db\Column objects describing a table public IndexInterface[] describeIndexes(string $table,string $schema = null) Lists table indexes public ReferenceInterface[] describeReferences(string $table,string $schema = null) Lists table references public bool dropColumn(string $tableName,string $schemaName,string $columnName) Drops a column from a table public bool dropForeignKey(string $tableName,string $schemaName,string $referenceName) Drops a foreign key from a table public bool dropIndex(string $tableName,string $schemaName,string $indexName) Drop an index from a table public bool dropPrimaryKey(string $tableName,string $schemaName) Drops primary key from a table public bool dropTable(string $tableName,string $schemaName = null,bool $ifExists = true) Drops a table from a schema/database public bool dropView(string $viewName,string $schemaName = null,bool $ifExists = true) Drops a view public string escapeIdentifier( mixed $identifier ) Escapes a column/table/schema name public string escapeString( string $str ) Escapes a value to avoid SQL injections public bool execute(string $sqlStatement,array $bindParams = [],array $bindTypes = []) Sends SQL statements to the database server returning the success state. public array fetchAll(string $sqlQuery,int $fetchMode = 2,array $bindParams = [],array $bindTypes = []) Dumps the complete result of a query into an array public string|bool fetchColumn(string $sqlQuery,array $placeholders = [],mixed $column = 0) Returns the n'th field of first row in a SQL query result public array fetchOne(string $sqlQuery,int $fetchMode = 2,array $bindParams = [],array $bindTypes = []) Returns the first row in a SQL query result public string forUpdate(string $sqlQuery,string $modifier = "") Returns a SQL modified with a FOR UPDATE clause. The optional modifier public string getColumnDefinition( ColumnInterface $column ) Returns the SQL column definition from a column public string getColumnList( mixed $columnList ) Gets a list of columns public int getConnectionId() Gets the active connection unique identifier public RawValue getDefaultIdValue() Return the default identity value to insert in an identity column public RawValue|null getDefaultValue() Returns the default value to make the RBDM use the default value declared public array getDescriptor() Return descriptor used to connect to the active database public DialectInterface getDialect() Returns internal dialect instance public string getDialectType() Returns the name of the dialect used public mixed getInternalHandler() Return internal PDO handler public string getNestedTransactionSavepointName() Returns the savepoint name to use for nested transactions public string getRealSQLStatement() Active SQL statement in the object without replace bound parameters public array getSQLBindTypes() Active SQL statement in the object public string getSQLStatement() Active SQL statement in the object public array getSQLVariables() Active SQL statement in the object public string getType() Returns type of database system the adapter is used for public bool insert(string $table,array $values,mixed $fields = null,mixed $dataTypes = null) Inserts data into a table using custom RDBMS SQL syntax public bool insertAsDict(string $table,mixed $data,mixed $dataTypes = null) Inserts data into a table using custom RBDM SQL syntax public bool isNestedTransactionsWithSavepoints() Returns if nested transactions should use savepoints public bool isUnderTransaction() Checks whether connection is under database transaction public string|bool lastInsertId( string $name = null ) Returns insert id for the auto_increment column inserted in the last SQL public string limit(string $sqlQuery,mixed $number) Appends a LIMIT clause to sqlQuery argument public array listTables( string $schemaName = null ) List all tables on a database public array listViews( string $schemaName = null ) List all views on a database public bool modifyColumn(string $tableName,string $schemaName,ColumnInterface $column,ColumnInterface $currentColumn = null) Modifies a table column based on a definition public ResultInterface|bool query(string $sqlStatement,array $bindParams = [],array $bindTypes = []) Sends SQL statements to the database server returning the success state. public bool releaseSavepoint( string $name ) Releases given savepoint public bool rollback( bool $nesting = true ) Rollbacks the active transaction in the connection public bool rollbackSavepoint( string $name ) Rollbacks given savepoint public \Phalcon\Db\Adapter\AdapterInterface setNestedTransactionsWithSavepoints( bool $nestedTransactionsWithSavepoints ) Set if nested transactions should use savepoints public string sharedLock(string $sqlQuery,string $modifier = "") Returns a SQL modified with a shared-lock clause. See the dialect's public bool supportSequences() Check whether the database system requires a sequence to produce public bool supportsDefaultValue() SQLite does not support the DEFAULT keyword public bool tableExists(string $tableName,string $schemaName = null) Generates SQL checking for the existence of a schema.table public array tableOptions(string $tableName,string $schemaName = null) Gets creation options from a table public bool update(string $table,mixed $fields,mixed $values,mixed $whereCondition = null,mixed $dataTypes = null) Updates data on a table using custom RDBMS SQL syntax public bool updateAsDict(string $table,mixed $data,mixed $whereCondition = null,mixed $dataTypes = null) Updates data on a table using custom RBDM SQL syntax public bool useExplicitIdValue() Check whether the database system requires an explicit value for identity public bool viewExists(string $viewName,string $schemaName = null) Generates SQL checking for the existence of a schema.view

Methods

Public · 67

addColumn()

public function addColumn(
    string $tableName,
    string $schemaName,
    ColumnInterface $column
): bool;

Adds a column to a table

addForeignKey()

public function addForeignKey(
    string $tableName,
    string $schemaName,
    ReferenceInterface $reference
): bool;

Adds a foreign key to a table

addIndex()

public function addIndex(
    string $tableName,
    string $schemaName,
    IndexInterface $index
): bool;

Adds an index to a table

addPrimaryKey()

public function addPrimaryKey(
    string $tableName,
    string $schemaName,
    IndexInterface $index
): bool;

Adds a primary key to a table

affectedRows()

public function affectedRows(): int;

Returns the number of affected rows by the last INSERT/UPDATE/DELETE reported by the database system

begin()

public function begin( bool $nesting = true ): bool;

Starts a transaction in the connection

close()

public function close(): void;

Closes active connection returning success. Phalcon automatically closes and destroys active connections within Phalcon\Db\Pool

commit()

public function commit( bool $nesting = true ): bool;

Commits the active transaction in the connection

connect()

public function connect( array $descriptor = [] ): void;

This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor. Call it when you need to restore a database connection

createSavepoint()

public function createSavepoint( string $name ): bool;

Creates a new savepoint

createTable()

public function createTable(
    string $tableName,
    string $schemaName,
    array $definition
): bool;

Creates a table

createView()

public function createView(
    string $viewName,
    array $definition,
    string $schemaName = null
): bool;

Creates a view

delete()

public function delete(
    mixed $table,
    string $whereCondition = null,
    array $placeholders = [],
    array $dataTypes = []
): bool;

Deletes data from a table using custom RDBMS SQL syntax

describeColumns()

public function describeColumns(
    string $table,
    string $schema = null
): ColumnInterface[];

Returns an array of Phalcon\Db\Column objects describing a table

describeIndexes()

public function describeIndexes(
    string $table,
    string $schema = null
): IndexInterface[];

Lists table indexes

describeReferences()

public function describeReferences(
    string $table,
    string $schema = null
): ReferenceInterface[];

Lists table references

dropColumn()

public function dropColumn(
    string $tableName,
    string $schemaName,
    string $columnName
): bool;

Drops a column from a table

dropForeignKey()

public function dropForeignKey(
    string $tableName,
    string $schemaName,
    string $referenceName
): bool;

Drops a foreign key from a table

dropIndex()

public function dropIndex(
    string $tableName,
    string $schemaName,
    string $indexName
): bool;

Drop an index from a table

dropPrimaryKey()

public function dropPrimaryKey(
    string $tableName,
    string $schemaName
): bool;

Drops primary key from a table

dropTable()

public function dropTable(
    string $tableName,
    string $schemaName = null,
    bool $ifExists = true
): bool;

Drops a table from a schema/database

dropView()

public function dropView(
    string $viewName,
    string $schemaName = null,
    bool $ifExists = true
): bool;

Drops a view

escapeIdentifier()

public function escapeIdentifier( mixed $identifier ): string;

Escapes a column/table/schema name

escapeString()

public function escapeString( string $str ): string;

Escapes a value to avoid SQL injections

execute()

public function execute(
    string $sqlStatement,
    array $bindParams = [],
    array $bindTypes = []
): bool;

Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server does not return any rows

fetchAll()

public function fetchAll(
    string $sqlQuery,
    int $fetchMode = 2,
    array $bindParams = [],
    array $bindTypes = []
): array;

Dumps the complete result of a query into an array

fetchColumn()

public function fetchColumn(
    string $sqlQuery,
    array $placeholders = [],
    mixed $column = 0
): string|bool;

Returns the n'th field of first row in a SQL query result

// Getting count of robots
$robotsCount = $connection->fetchColumn("SELECT COUNT(*) FROM robots");
print_r($robotsCount);

// Getting name of last edited robot
$robot = $connection->fetchColumn(
    "SELECT id, name FROM robots ORDER BY modified DESC",
    1
);
print_r($robot);

fetchOne()

public function fetchOne(
    string $sqlQuery,
    int $fetchMode = 2,
    array $bindParams = [],
    array $bindTypes = []
): array;

Returns the first row in a SQL query result

forUpdate()

public function forUpdate(
    string $sqlQuery,
    string $modifier = ""
): string;

Returns a SQL modified with a FOR UPDATE clause. The optional modifier appends a row-lock disposition keyword - pass Dialect::LOCK_NOWAIT or Dialect::LOCK_SKIP_LOCKED (or leave as Dialect::LOCK_NONE).

getColumnDefinition()

public function getColumnDefinition( ColumnInterface $column ): string;

Returns the SQL column definition from a column

getColumnList()

public function getColumnList( mixed $columnList ): string;

Gets a list of columns

getConnectionId()

public function getConnectionId(): int;

Gets the active connection unique identifier

getDefaultIdValue()

public function getDefaultIdValue(): RawValue;

Return the default identity value to insert in an identity column

getDefaultValue()

public function getDefaultValue(): RawValue|null;

Returns the default value to make the RBDM use the default value declared in the table definition

// Inserting a new robot with a valid default value for the column 'year'
$success = $connection->insert(
    "robots",
    [
        "Astro Boy",
        $connection->getDefaultValue()
    ],
    [
        "name",
        "year",
    ]
);

@todo Return NULL if this is not supported by the adapter

getDescriptor()

public function getDescriptor(): array;

Return descriptor used to connect to the active database

getDialect()

public function getDialect(): DialectInterface;

Returns internal dialect instance

getDialectType()

public function getDialectType(): string;

Returns the name of the dialect used

getInternalHandler()

public function getInternalHandler(): mixed;

Return internal PDO handler

getNestedTransactionSavepointName()

public function getNestedTransactionSavepointName(): string;

Returns the savepoint name to use for nested transactions

getRealSQLStatement()

public function getRealSQLStatement(): string;

Active SQL statement in the object without replace bound parameters

getSQLBindTypes()

public function getSQLBindTypes(): array;

Active SQL statement in the object

getSQLStatement()

public function getSQLStatement(): string;

Active SQL statement in the object

getSQLVariables()

public function getSQLVariables(): array;

Active SQL statement in the object

getType()

public function getType(): string;

Returns type of database system the adapter is used for

insert()

public function insert(
    string $table,
    array $values,
    mixed $fields = null,
    mixed $dataTypes = null
): bool;

Inserts data into a table using custom RDBMS SQL syntax

insertAsDict()

public function insertAsDict(
    string $table,
    mixed $data,
    mixed $dataTypes = null
): bool;

Inserts data into a table using custom RBDM SQL syntax

// Inserting a new robot
$success = $connection->insertAsDict(
    "robots",
    [
        "name" => "Astro Boy",
        "year" => 1952,
    ]
);

// Next SQL sentence is sent to the database system
INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);

isNestedTransactionsWithSavepoints()

public function isNestedTransactionsWithSavepoints(): bool;

Returns if nested transactions should use savepoints

isUnderTransaction()

public function isUnderTransaction(): bool;

Checks whether connection is under database transaction

lastInsertId()

public function lastInsertId( string $name = null ): string|bool;

Returns insert id for the auto_increment column inserted in the last SQL statement

limit()

public function limit(
    string $sqlQuery,
    mixed $number
): string;

Appends a LIMIT clause to sqlQuery argument

listTables()

public function listTables( string $schemaName = null ): array;

List all tables on a database

listViews()

public function listViews( string $schemaName = null ): array;

List all views on a database

modifyColumn()

public function modifyColumn(
    string $tableName,
    string $schemaName,
    ColumnInterface $column,
    ColumnInterface $currentColumn = null
): bool;

Modifies a table column based on a definition

query()

public function query(
    string $sqlStatement,
    array $bindParams = [],
    array $bindTypes = []
): ResultInterface|bool;

Sends SQL statements to the database server returning the success state. Use this method only when the SQL statement sent to the server returns rows

releaseSavepoint()

public function releaseSavepoint( string $name ): bool;

Releases given savepoint

rollback()

public function rollback( bool $nesting = true ): bool;

Rollbacks the active transaction in the connection

rollbackSavepoint()

public function rollbackSavepoint( string $name ): bool;

Rollbacks given savepoint

setNestedTransactionsWithSavepoints()

public function setNestedTransactionsWithSavepoints( bool $nestedTransactionsWithSavepoints ): \Phalcon\Db\Adapter\AdapterInterface;

Set if nested transactions should use savepoints

sharedLock()

public function sharedLock(
    string $sqlQuery,
    string $modifier = ""
): string;

Returns a SQL modified with a shared-lock clause. See the dialect's sharedLock() for per-engine semantics. The optional modifier is passed straight through (use Dialect::LOCK_NOWAIT / Dialect::LOCK_SKIP_LOCKED for PostgreSQL).

supportSequences()

public function supportSequences(): bool;

Check whether the database system requires a sequence to produce auto-numeric values

supportsDefaultValue()

public function supportsDefaultValue(): bool;

SQLite does not support the DEFAULT keyword

tableExists()

public function tableExists(
    string $tableName,
    string $schemaName = null
): bool;

Generates SQL checking for the existence of a schema.table

tableOptions()

public function tableOptions(
    string $tableName,
    string $schemaName = null
): array;

Gets creation options from a table

update()

public function update(
    string $table,
    mixed $fields,
    mixed $values,
    mixed $whereCondition = null,
    mixed $dataTypes = null
): bool;

Updates data on a table using custom RDBMS SQL syntax

updateAsDict()

public function updateAsDict(
    string $table,
    mixed $data,
    mixed $whereCondition = null,
    mixed $dataTypes = null
): bool;

Updates data on a table using custom RBDM SQL syntax Another, more convenient syntax

// Updating existing robot
$success = $connection->updateAsDict(
    "robots",
    [
        "name" => "New Astro Boy",
    ],
    "id = 101"
);

// Next SQL sentence is sent to the database system
UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101

useExplicitIdValue()

public function useExplicitIdValue(): bool;

Check whether the database system requires an explicit value for identity columns

viewExists()

public function viewExists(
    string $viewName,
    string $schemaName = null
): bool;

Generates SQL checking for the existence of a schema.view

Contracts\Db\Check

Interface Source on GitHub

Canonical contract for Phalcon\Db\Check.

Method Summary

Methods

Public · 2

getExpression()

public function getExpression(): string;

Gets the CHECK expression (the SQL boolean predicate).

getName()

public function getName(): string;

Gets the constraint name. An empty string indicates an unnamed CHECK constraint - the dialect will emit the clause without a CONSTRAINT prefix in that case.

Contracts\Db\Column

Interface Source on GitHub

Canonical contract for Phalcon\Db\Column.

@todo v7 - these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - getGenerationExpression() : string | null - isArray() : bool - isGenerated() : bool - isGenerationStored() : bool - isInvisible() : bool

Method Summary

Methods

Public · 16

getAfterPosition()

public function getAfterPosition(): string|null;

Check whether field absolute to position in table

getBindType()

public function getBindType(): int;

Returns the type of bind handling

getDefault()

public function getDefault(): mixed;

Returns default value of column

getName()

public function getName(): string;

Returns column name

getScale()

public function getScale(): int;

Returns column scale

getSize()

public function getSize(): int|string;

Returns column size

getType()

public function getType(): int|string;

Returns column type

getTypeReference()

public function getTypeReference(): int;

Returns column type reference

getTypeValues()

public function getTypeValues(): array|string|int;

Returns column type values

hasDefault()

public function hasDefault(): bool;

Check whether column has default value

isAutoIncrement()

public function isAutoIncrement(): bool;

Auto-Increment

isFirst()

public function isFirst(): bool;

Check whether column have first position in table

isNotNull()

public function isNotNull(): bool;

Not null

isNumeric()

public function isNumeric(): bool;

Check whether column have an numeric type

isPrimary()

public function isPrimary(): bool;

Column is part of the primary key?

isUnsigned()

public function isUnsigned(): bool;

Returns true if number column is unsigned

Contracts\Db\Dialect

Interface Source on GitHub

Canonical contract for Phalcon\Db dialects.

@todo v7 - these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - addCheck() : string - createMaterializedView() : string - dropCheck() : string - dropMaterializedView() : string - onConflictUpdate() : string - refreshMaterializedView() : string - returning() : string

Uses Phalcon\Db\ColumnInterface · Phalcon\Db\IndexInterface · Phalcon\Db\ReferenceInterface

Method Summary

public string addColumn(string $tableName,string $schemaName,ColumnInterface $column) Generates SQL to add a column to a table public string addForeignKey(string $tableName,string $schemaName,ReferenceInterface $reference) Generates SQL to add an index to a table public string addIndex(string $tableName,string $schemaName,IndexInterface $index) Generates SQL to add an index to a table public string addPrimaryKey(string $tableName,string $schemaName,IndexInterface $index) Generates SQL to add the primary key to a table public string createSavepoint( string $name ) Generate SQL to create a new savepoint public string createTable(string $tableName,string $schemaName,array $definition) Generates SQL to create a table public string createView(string $viewName,array $definition,string $schemaName = null) Generates SQL to create a view public string describeColumns(string $table,string $schema = null) Generates SQL to describe a table public string describeIndexes(string $table,string $schema = null) Generates SQL to query indexes on a table. public string describeReferences(string $table,string $schema = null) Generates SQL to query foreign keys on a table. public string dropColumn(string $tableName,string $schemaName,string $columnName) Generates SQL to delete a column from a table public string dropForeignKey(string $tableName,string $schemaName,string $referenceName) Generates SQL to delete a foreign key from a table public string dropIndex(string $tableName,string $schemaName,string $indexName) Generates SQL to delete an index from a table public string dropPrimaryKey(string $tableName,string $schemaName) Generates SQL to delete primary key from a table public string dropTable(string $tableName,string $schemaName,bool $ifExists = true) Generates SQL to drop a table public string dropView(string $viewName,string $schemaName = null,bool $ifExists = true) Generates SQL to drop a view public string forUpdate(string $sqlQuery,string $modifier = "") Returns a SQL modified with a FOR UPDATE clause. The optional modifier public string getColumnDefinition( ColumnInterface $column ) Gets the column name in RDBMS public string getColumnList( array $columnList ) Gets a list of columns public array getCustomFunctions() Returns registered functions public string getSqlExpression(array $expression,string $escapeChar = null,array $bindCounts = []) Transforms an intermediate representation for an expression into a public string limit(string $sqlQuery,mixed $number) Generates the SQL for LIMIT clause public string listTables( string $schemaName = null ) List all tables in database public string modifyColumn(string $tableName,string $schemaName,ColumnInterface $column,ColumnInterface $currentColumn = null) Generates SQL to modify a column in a table public \Phalcon\Db\Dialect registerCustomFunction(string $name,callable $customFunction) Registers custom SQL functions public string releaseSavepoint( string $name ) Generate SQL to release a savepoint public string rollbackSavepoint( string $name ) Generate SQL to rollback a savepoint public string select( array $definition ) Builds a SELECT statement public string sharedLock(string $sqlQuery,string $modifier = "") Returns a SQL modified with a shared-lock clause. MySQL emits public bool supportsReleaseSavepoints() Checks whether the platform supports releasing savepoints. public bool supportsSavepoints() Checks whether the platform supports savepoints public string tableExists(string $tableName,string $schemaName = null) Generates SQL checking for the existence of a schema.table public string tableOptions(string $table,string $schema = null) Generates the SQL to describe the table creation options public string viewExists(string $viewName,string $schemaName = null) Generates SQL checking for the existence of a schema.view

Constants

string LOCK_NONE = "" No row-lock modifier - the default behavior for forUpdate().
string LOCK_NOWAIT = "NOWAIT" Append NOWAIT to the FOR UPDATE clause - the query fails immediately if a row it needs is locked instead of blocking. MySQL 8.0+ and PostgreSQL 9.5+ recognize this. SQLite has no row-level locking and silently ignores the modifier.
string LOCK_SKIP_LOCKED = "SKIP LOCKED" Append SKIP LOCKED to the FOR UPDATE clause - the query returns rows that are not currently locked and silently skips ones that are. MySQL 8.0+ and PostgreSQL 9.5+ recognize this. SQLite ignores it.

Methods

Public · 34

addColumn()

public function addColumn(
    string $tableName,
    string $schemaName,
    ColumnInterface $column
): string;

Generates SQL to add a column to a table

addForeignKey()

public function addForeignKey(
    string $tableName,
    string $schemaName,
    ReferenceInterface $reference
): string;

Generates SQL to add an index to a table

addIndex()

public function addIndex(
    string $tableName,
    string $schemaName,
    IndexInterface $index
): string;

Generates SQL to add an index to a table

addPrimaryKey()

public function addPrimaryKey(
    string $tableName,
    string $schemaName,
    IndexInterface $index
): string;

Generates SQL to add the primary key to a table

createSavepoint()

public function createSavepoint( string $name ): string;

Generate SQL to create a new savepoint

createTable()

public function createTable(
    string $tableName,
    string $schemaName,
    array $definition
): string;

Generates SQL to create a table

createView()

public function createView(
    string $viewName,
    array $definition,
    string $schemaName = null
): string;

Generates SQL to create a view

describeColumns()

public function describeColumns(
    string $table,
    string $schema = null
): string;

Generates SQL to describe a table

describeIndexes()

public function describeIndexes(
    string $table,
    string $schema = null
): string;

Generates SQL to query indexes on a table.

The base adapter consumes the result as FETCH_NUM rows by position: column index 2 must be the index key name and column index 4 the indexed column name.

describeReferences()

public function describeReferences(
    string $table,
    string $schema = null
): string;

Generates SQL to query foreign keys on a table.

The base adapter consumes the result as FETCH_NUM rows by position: index 1 the local column, index 2 the constraint name, index 3 the referenced schema, index 4 the referenced table, and index 5 the referenced column.

dropColumn()

public function dropColumn(
    string $tableName,
    string $schemaName,
    string $columnName
): string;

Generates SQL to delete a column from a table

dropForeignKey()

public function dropForeignKey(
    string $tableName,
    string $schemaName,
    string $referenceName
): string;

Generates SQL to delete a foreign key from a table

dropIndex()

public function dropIndex(
    string $tableName,
    string $schemaName,
    string $indexName
): string;

Generates SQL to delete an index from a table

dropPrimaryKey()

public function dropPrimaryKey(
    string $tableName,
    string $schemaName
): string;

Generates SQL to delete primary key from a table

dropTable()

public function dropTable(
    string $tableName,
    string $schemaName,
    bool $ifExists = true
): string;

Generates SQL to drop a table

dropView()

public function dropView(
    string $viewName,
    string $schemaName = null,
    bool $ifExists = true
): string;

Generates SQL to drop a view

forUpdate()

public function forUpdate(
    string $sqlQuery,
    string $modifier = ""
): string;

Returns a SQL modified with a FOR UPDATE clause. The optional modifier appends a row-lock disposition keyword - pass Dialect::LOCK_NOWAIT or Dialect::LOCK_SKIP_LOCKED (or leave as Dialect::LOCK_NONE).

getColumnDefinition()

public function getColumnDefinition( ColumnInterface $column ): string;

Gets the column name in RDBMS

getColumnList()

public function getColumnList( array $columnList ): string;

Gets a list of columns

getCustomFunctions()

public function getCustomFunctions(): array;

Returns registered functions

getSqlExpression()

public function getSqlExpression(
    array $expression,
    string $escapeChar = null,
    array $bindCounts = []
): string;

Transforms an intermediate representation for an expression into a database system valid expression

limit()

public function limit(
    string $sqlQuery,
    mixed $number
): string;

Generates the SQL for LIMIT clause

listTables()

public function listTables( string $schemaName = null ): string;

List all tables in database

modifyColumn()

public function modifyColumn(
    string $tableName,
    string $schemaName,
    ColumnInterface $column,
    ColumnInterface $currentColumn = null
): string;

Generates SQL to modify a column in a table

registerCustomFunction()

public function registerCustomFunction(
    string $name,
    callable $customFunction
): \Phalcon\Db\Dialect;

Registers custom SQL functions

releaseSavepoint()

public function releaseSavepoint( string $name ): string;

Generate SQL to release a savepoint

rollbackSavepoint()

public function rollbackSavepoint( string $name ): string;

Generate SQL to rollback a savepoint

select()

public function select( array $definition ): string;

Builds a SELECT statement

sharedLock()

public function sharedLock(
    string $sqlQuery,
    string $modifier = ""
): string;

Returns a SQL modified with a shared-lock clause. MySQL emits LOCK IN SHARE MODE; PostgreSQL emits FOR SHARE; SQLite returns the original query unchanged. The optional modifier appends a row-lock disposition keyword (Dialect::LOCK_NOWAIT / Dialect::LOCK_SKIP_LOCKED) for PostgreSQL - MySQL's legacy LOCK IN SHARE MODE does not support modifiers, so non-empty values are silently ignored on MySQL.

supportsReleaseSavepoints()

public function supportsReleaseSavepoints(): bool;

Checks whether the platform supports releasing savepoints.

supportsSavepoints()

public function supportsSavepoints(): bool;

Checks whether the platform supports savepoints

tableExists()

public function tableExists(
    string $tableName,
    string $schemaName = null
): string;

Generates SQL checking for the existence of a schema.table

tableOptions()

public function tableOptions(
    string $table,
    string $schema = null
): string;

Generates the SQL to describe the table creation options

viewExists()

public function viewExists(
    string $viewName,
    string $schemaName = null
): string;

Generates SQL checking for the existence of a schema.view

Contracts\Db\Geometry\Geometry

Interface Source on GitHub

Canonical contract for Phalcon\Db\Geometry value objects.

Method Summary

Methods

Public · 3

getSrid()

public function getSrid(): int;

Gets the Spatial Reference System Identifier (SRID).

getType()

public function getType(): int;

Gets the geometry type.

toWkt()

public function toWkt(): string;

Renders the geometry as a Well-Known Text (WKT) string.

Contracts\Db\Index

Interface Source on GitHub

Canonical contract for Phalcon\Db\Index.

@todo v7 - these will become required interface members. They are omitted from the v5 line to avoid breaking third-party implementors: - getDirections() : array - getWhere() : string - isConcurrent() : bool - isInvisible() : bool

Method Summary

Methods

Public · 3

getColumns()

public function getColumns(): array;

Gets the columns that corresponds the index

getName()

public function getName(): string;

Gets the index name

getType()

public function getType(): string;

Gets the index type

Contracts\Db\Reference

Interface Source on GitHub

Canonical contract for Phalcon\Db\Reference.

Method Summary

Methods

Public · 8

getColumns()

public function getColumns(): array;

Gets local columns which reference is based

getName()

public function getName(): string;

Gets the index name

getOnDelete()

public function getOnDelete(): string|null;

Gets the referenced on delete

getOnUpdate()

public function getOnUpdate(): string|null;

Gets the referenced on update

getReferencedColumns()

public function getReferencedColumns(): array;

Gets referenced columns

getReferencedSchema()

public function getReferencedSchema(): string|null;

Gets the schema where referenced table is

getReferencedTable()

public function getReferencedTable(): string;

Gets the referenced table

getSchemaName()

public function getSchemaName(): string|null;

Gets the schema where referenced table is

Contracts\Db\Result

Interface Source on GitHub

Canonical contract for Phalcon\Db result objects.

Method Summary

Methods

Public · 8

dataSeek()

public function dataSeek( int $number );

Moves internal resultset cursor to another position letting us to fetch a certain row

execute()

public function execute(): bool;

Allows to execute the statement again. Some database systems don't support scrollable cursors. So, as cursors are forward only, we need to execute the cursor again to fetch rows from the beginning

fetch()

public function fetch(): mixed;

Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode()

fetchAll()

public function fetchAll(): array;

Returns an array of arrays containing all the records in the result. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode()

fetchArray()

public function fetchArray(): mixed;

Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode()

getInternalResult()

public function getInternalResult(): \PDOStatement;

Gets the internal PDO result object

numRows()

public function numRows(): int;

Gets number of rows returned by a resultset

setFetchMode()

public function setFetchMode( int $fetchMode ): bool;

Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch()

Contracts\Dispatcher\Dispatcher

Interface Source on GitHub

Canonical contract for Phalcon\Dispatcher\AbstractDispatcher.

Note: The deprecated getParam()/getParams()/hasParam()/setParam()/ setParams() spellings are still declared for backwards compatibility and are scheduled to be removed in the next major version in favor of their *Parameter counterparts.

Method Summary

public mixed|bool dispatch() Dispatches a handle action taking into account the routing parameters public void forward( array $forward ) Forwards the execution flow to another controller/action public string getActionName() Gets last dispatched action name public string getActionSuffix() Gets the default action suffix public string getHandlerSuffix() Gets the default handler suffix public mixed getParam(mixed $param,mixed $filters = null) Gets a param by its name or numeric index public mixed getParameter(mixed $param,mixed $filters = null) Gets a param by its name or numeric index public array getParameters() Gets action params public array getParams() Gets action params public mixed getReturnedValue() Returns value returned by the latest dispatched action public bool hasParam( mixed $param ) Check if a param exists public bool isFinished() Checks if the dispatch loop is finished or has more pendent public void setActionName( string $actionName ) Sets the action name to be dispatched public void setActionSuffix( string $actionSuffix ) Sets the default action suffix public void setDefaultAction( string $actionName ) Sets the default action name public void setDefaultNamespace( string $defaultNamespace ) Sets the default namespace public void setHandlerSuffix( string $handlerSuffix ) Sets the default suffix for the handler public void setModuleName( string $moduleName = null ) Sets the module name which the application belongs to public void setNamespaceName( string $namespaceName ) Sets the namespace which the controller belongs to public void setParam(mixed $param,mixed $value) Set a param by its name or numeric index public void setParams( array $params ) Sets action params to be dispatched

Methods

Public · 21

dispatch()

public function dispatch(): mixed|bool;

Dispatches a handle action taking into account the routing parameters

forward()

public function forward( array $forward ): void;

Forwards the execution flow to another controller/action

getActionName()

public function getActionName(): string;

Gets last dispatched action name

getActionSuffix()

public function getActionSuffix(): string;

Gets the default action suffix

getHandlerSuffix()

public function getHandlerSuffix(): string;

Gets the default handler suffix

getParam()

public function getParam(
    mixed $param,
    mixed $filters = null
): mixed;

Gets a param by its name or numeric index

Note: This signature omits the defaultValue argument the implementation accepts; the two will be aligned in the next major version.

getParameter()

public function getParameter(
    mixed $param,
    mixed $filters = null
): mixed;

Gets a param by its name or numeric index

getParameters()

public function getParameters(): array;

Gets action params

getParams()

public function getParams(): array;

Gets action params

getReturnedValue()

public function getReturnedValue(): mixed;

Returns value returned by the latest dispatched action

hasParam()

public function hasParam( mixed $param ): bool;

Check if a param exists

isFinished()

public function isFinished(): bool;

Checks if the dispatch loop is finished or has more pendent controllers/tasks to dispatch

setActionName()

public function setActionName( string $actionName ): void;

Sets the action name to be dispatched

setActionSuffix()

public function setActionSuffix( string $actionSuffix ): void;

Sets the default action suffix

setDefaultAction()

public function setDefaultAction( string $actionName ): void;

Sets the default action name

setDefaultNamespace()

public function setDefaultNamespace( string $defaultNamespace ): void;

Sets the default namespace

setHandlerSuffix()

public function setHandlerSuffix( string $handlerSuffix ): void;

Sets the default suffix for the handler

setModuleName()

public function setModuleName( string $moduleName = null ): void;

Sets the module name which the application belongs to

setNamespaceName()

public function setNamespaceName( string $namespaceName ): void;

Sets the namespace which the controller belongs to

setParam()

public function setParam(
    mixed $param,
    mixed $value
): void;

Set a param by its name or numeric index

setParams()

public function setParams( array $params ): void;

Sets action params to be dispatched

Contracts\Domain\Payload\Payload

Interface Source on GitHub

Canonical combined read/write contract for a domain payload.

Payload extends both Writeable and Readable, exposing the full capability set. The intended convention narrows that surface by which side of the Action-Domain-Responder boundary holds the payload: the domain layer builds the payload through Writeable (the setters), while the responder consumes the finished payload through Readable (the getters). Type-hinting against the narrower contract at each boundary keeps each side to the capability it needs, even though the concrete payload implements both.

@see Readable @see Writeable

Contracts\Domain\Payload\Readable

Interface Source on GitHub

Canonical read-only contract for a domain payload.

Responders consume a finished payload through this contract (the getters), narrowing the surface to the read side of the Action-Domain-Responder boundary.

Uses Throwable

Method Summary

Methods

Public · 6

getException()

public function getException(): Throwable|null;

Gets the potential exception thrown in the domain layer

getExtras()

public function getExtras(): mixed;

Gets arbitrary extra values produced by the domain layer.

getInput()

public function getInput(): mixed;

Gets the input received by the domain layer.

getMessages()

public function getMessages(): mixed;

Gets the messages produced by the domain layer.

getOutput()

public function getOutput(): mixed;

Gets the output produced from the domain layer.

getStatus()

public function getStatus(): mixed;

Gets the status of this payload.

Status values are drawn from the Status vocabulary.

@see \Phalcon\Domain\Payload\Status

Contracts\Domain\Payload\Writeable

Interface Source on GitHub

Canonical write-only contract for a domain payload.

The domain layer builds a payload through this contract (the setters), narrowing the surface to the write side of the Action-Domain-Responder boundary.

Uses Throwable

Method Summary

Methods

Public · 6

setException()

public function setException( Throwable $exception ): Payload;

Sets an exception produced by the domain layer.

setExtras()

public function setExtras( mixed $extras ): Payload;

Sets arbitrary extra values produced by the domain layer.

setInput()

public function setInput( mixed $input ): Payload;

Sets the input received by the domain layer.

setMessages()

public function setMessages( mixed $messages ): Payload;

Sets the messages produced by the domain layer.

setOutput()

public function setOutput( mixed $output ): Payload;

Sets the output produced from the domain layer.

setStatus()

public function setStatus( mixed $status ): Payload;

Sets the status of this payload.

Status values are drawn from the Status vocabulary.

@see \Phalcon\Domain\Payload\Status

Contracts\Encryption\Crypt\Crypt

Interface Source on GitHub

Canonical contract for Phalcon\Encryption\Crypt.

The encrypted payload produced by encrypt() uses the wire format:

iv ‖ hmac ‖ ciphertext ‖ tag

where hmac is present only when signing is enabled (useSigning(true), the default) and tag is present only for AEAD ciphers (gcm/ccm).

The AEAD parameters (authData, authTag, authTagLength) are instance state set through the relevant setters and shared across every encrypt()/decrypt() call on the instance. A Crypt service shared through the DI container is therefore not safe for interleaved AEAD operations.

Method Summary

Methods

Public · 17

decrypt()

public function decrypt(
    string $input,
    string $key = null
): string;

Decrypts a text

decryptBase64()

public function decryptBase64(
    string $input,
    string $key = null
): string;

Decrypt a text that is coded as a base64 string

encrypt()

public function encrypt(
    string $input,
    string $key = null
): string;

Encrypts a text

encryptBase64()

public function encryptBase64(
    string $input,
    string $key = null
): string;

Encrypts a text returning the result as a base64 string

getAuthData()

public function getAuthData(): string;

Returns authentication data

getAuthTag()

public function getAuthTag(): string;

Returns the authentication tag

getAuthTagLength()

public function getAuthTagLength(): int;

Returns the authentication tag length

getAvailableCiphers()

public function getAvailableCiphers(): array;

Returns a list of available cyphers

getCipher()

public function getCipher(): string;

Returns the current cipher

getKey()

public function getKey(): string;

Returns the encryption key

setAuthData()

public function setAuthData( string $data ): Crypt;

Sets authentication data

setAuthTag()

public function setAuthTag( string $tag ): Crypt;

Sets the authentication tag

setAuthTagLength()

public function setAuthTagLength( int $length ): Crypt;

Sets the authentication tag length

setCipher()

public function setCipher( string $cipher ): Crypt;

Sets the cipher algorithm

setKey()

public function setKey( string $key ): Crypt;

Sets the encryption key

setPadding()

public function setPadding( int $scheme ): Crypt;

Changes the padding scheme used.

useSigning()

public function useSigning( bool $useSigning ): Crypt;

Sets if the calculating message digest must be used.

Contracts\Encryption\Crypt\Padding\Pad

Interface Source on GitHub

Canonical contract for Phalcon\Encryption\Crypt\Padding strategies.

The pad/unpad protocol operates on binary (8-bit) data. Implementations must measure and slice the input with byte-true functions (strlen, substr, or the mb_* family with the explicit "8bit" encoding); using encoding-sensitive functions such as mb_strlen() on the padded plaintext yields the wrong padding size whenever the bytes form valid multibyte sequences.

Method Summary

Methods

Public · 2

pad()

public function pad( int $paddingSize ): string;

unpad()

public function unpad(
    string $input,
    int $blockSize
): int;

Contracts\Encryption\Security\CryptoUtils

Interface Source on GitHub

Uses Phalcon\Encryption\Security\Random

Method Summary

Methods

Public · 5

computeHmac()

public function computeHmac(
    string $data,
    string $key,
    string $algorithm,
    bool $raw = false
): string;

getRandom()

public function getRandom(): Random;

getRandomBytes()

public function getRandomBytes(): int;

getSaltBytes()

public function getSaltBytes( int $numberBytes = 0 ): string;

setRandomBytes()

public function setRandomBytes( int $randomBytes ): Security;

Contracts\Encryption\Security\CsrfProtection

Interface Source on GitHub

  • Phalcon\Contracts\Encryption\Security\CsrfProtection

Method Summary

Methods

Public · 6

checkToken()

public function checkToken(
    string $tokenKey = null,
    mixed $tokenValue = null,
    bool $destroyIfValid = true
): bool;

destroyToken()

public function destroyToken(): Security;

getRequestToken()

public function getRequestToken(): string|null;

getSessionToken()

public function getSessionToken(): string|null;

getToken()

public function getToken(): string|null;

getTokenKey()

public function getTokenKey(): string|null;

Contracts\Encryption\Security\JWT\Signer\Signer

Interface Source on GitHub

Canonical contract for JWT Signer classes

Method Summary

Methods

Public · 4

getAlgHeader()

public function getAlgHeader(): string;

Return the value that is used for the "alg" header

getAlgorithm()

public function getAlgorithm(): string;

Return the algorithm used

sign()

public function sign(
    string $payload,
    string $passphrase
): string;

Sign a payload using the passphrase

verify()

public function verify(
    string $source,
    string $payload,
    string $passphrase
): bool;

Verify a passed source with a payload and passphrase

Contracts\Encryption\Security\PasswordSecurity

Interface Source on GitHub

  • Phalcon\Contracts\Encryption\Security\PasswordSecurity

Method Summary

Methods

Public · 8

checkHash()

public function checkHash(
    string $password,
    string $passwordHash,
    int $maxPassLength = 0
): bool;

getDefaultHash()

public function getDefaultHash(): int;

getHashInformation()

public function getHashInformation( string $hash ): array;

getWorkFactor()

public function getWorkFactor(): int;

hash()

public function hash(
    string $password,
    array $options = []
): string;

isLegacyHash()

public function isLegacyHash( string $passwordHash ): bool;

setDefaultHash()

public function setDefaultHash( int $defaultHash ): Security;

setWorkFactor()

public function setWorkFactor( int $workFactor ): Security;

Contracts\Encryption\Security\Security

Interface Source on GitHub

Contracts\Encryption\Security\Uuid\NodeProvider

Interface Source on GitHub

Method Summary

Methods

Public · 1

getNode()

public function getNode(): string;

Contracts\Encryption\Security\Uuid\TimeBasedUuid

Interface Source on GitHub

Method Summary

Methods

Public · 2

getDateTime()

public function getDateTime(): \DateTimeImmutable;

getNode()

public function getNode(): string;

Contracts\Encryption\Security\Uuid\Uuid

Interface Source on GitHub

Canonical marker contract for UUID version adapters.

Also carries the standard RFC 4122 namespace UUIDs as constants.

Constants

string NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
string NAMESPACE_OID = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
string NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
string NAMESPACE_X500 = "6ba7b814-9dad-11d1-80b4-00c04fd430c8"

Contracts\Events\Event

Interface Source on GitHub

Canonical contract for Phalcon\Events\Event.

Method Summary

Methods

Public · 7

getData()

public function getData(): mixed;

Gets event data

getType()

public function getType(): mixed;

Gets event type

isCancelable()

public function isCancelable(): bool;

Check whether the event is cancelable

isStopped()

public function isStopped(): bool;

Check whether the event is currently stopped

setData()

public function setData( mixed $data = null ): Event;

Sets event data

setType()

public function setType( string $type ): Event;

Sets event type

stop()

public function stop(): Event;

Stops the event preventing propagation

Contracts\Events\EventsAware

Interface Source on GitHub

Canonical contract for Phalcon\Events\EventsAwareInterface. Implemented by components that accept an events manager and dispatch through it.

Cross-references the legacy ManagerInterface (not the canonical Manager contract) to preserve LSP for the many AbstractEventsAware subclasses that already type-hint ManagerInterface. ManagerInterface extends Manager, so this remains type-compatible with any code that needs the canonical surface.

Uses Phalcon\Events\ManagerInterface

Method Summary

Methods

Public · 2

getEventsManager()

public function getEventsManager(): ManagerInterface|null;

Returns the internal events manager

setEventsManager()

public function setEventsManager( ManagerInterface $eventsManager ): void;

Sets the events manager

Contracts\Events\Manager

Interface Source on GitHub

Canonical contract for Phalcon\Events\Manager.

Method Summary

public void addSubscriber( Subscriber $subscriber ) Registers an event subscriber. The subscriber's getSubscribedEvents() public bool arePrioritiesEnabled() Returns whether priority ordering is currently enabled. public void attach(string $eventType,mixed $handler,int $priority = self::DEFAULT_PRIORITY) Attach a listener to the events manager. public void clearSubscribers() Removes every registered subscriber and detaches each listener they public void collectResponses( bool $collect ) Toggle response collection on/off. public void detach(string $eventType,mixed $handler) Detach a listener from the events manager. public void detachAll( string $type = null ) Removes all listeners - globally or for a single event type. public void enablePriorities( bool $enablePriorities ) Toggle priority ordering on/off. public fire(string $eventType,object $source,mixed $data = null,bool $cancelable = true) Fires an event, notifying the active listeners. public array getListeners( string $type ) Returns all listeners attached to the given event type. public array getResponses() Returns the responses recorded during the last fire (when collecting). public array getSubscribers() Returns the list of registered subscriber instances. public bool hasListeners( string $type ) Check whether the given event type has any listeners. public bool isCollecting() Check whether the manager is currently collecting responses. public bool isValidHandler( mixed $handler ) Returns true when the given handler is an object or callable. public void removeSubscriber( Subscriber $subscriber ) Removes a previously registered subscriber. Detaches every listener the

Constants

int DEFAULT_PRIORITY = 100

Methods

Public · 16

addSubscriber()

public function addSubscriber( Subscriber $subscriber ): void;

Registers an event subscriber. The subscriber's getSubscribedEvents() map is parsed and each entry is attached through the regular listener pipeline.

arePrioritiesEnabled()

public function arePrioritiesEnabled(): bool;

Returns whether priority ordering is currently enabled.

attach()

public function attach(
    string $eventType,
    mixed $handler,
    int $priority = self::DEFAULT_PRIORITY
): void;

Attach a listener to the events manager.

clearSubscribers()

public function clearSubscribers(): void;

Removes every registered subscriber and detaches each listener they contributed. Listeners attached via attach() are untouched.

collectResponses()

public function collectResponses( bool $collect ): void;

Toggle response collection on/off.

detach()

public function detach(
    string $eventType,
    mixed $handler
): void;

Detach a listener from the events manager.

detachAll()

public function detachAll( string $type = null ): void;

Removes all listeners - globally or for a single event type.

enablePriorities()

public function enablePriorities( bool $enablePriorities ): void;

Toggle priority ordering on/off.

fire()

public function fire(
    string $eventType,
    object $source,
    mixed $data = null,
    bool $cancelable = true
);

Fires an event, notifying the active listeners.

getListeners()

public function getListeners( string $type ): array;

Returns all listeners attached to the given event type.

getResponses()

public function getResponses(): array;

Returns the responses recorded during the last fire (when collecting).

getSubscribers()

public function getSubscribers(): array;

Returns the list of registered subscriber instances.

hasListeners()

public function hasListeners( string $type ): bool;

Check whether the given event type has any listeners.

isCollecting()

public function isCollecting(): bool;

Check whether the manager is currently collecting responses.

isValidHandler()

public function isValidHandler( mixed $handler ): bool;

Returns true when the given handler is an object or callable.

removeSubscriber()

public function removeSubscriber( Subscriber $subscriber ): void;

Removes a previously registered subscriber. Detaches every listener the subscriber declared via getSubscribedEvents(). Idempotent.

Contracts\Events\Stoppable

Interface Source on GitHub

Phalcon's local mirror of PSR-14 StoppableEventInterface. Identical shape; not extended from the PSR interface because the Zephir extension cannot reference Composer-loaded interfaces at build time. A separate bridge package exposes a PSR-14 adapter.

  • Phalcon\Contracts\Events\Stoppable

Method Summary

Methods

Public · 1

isPropagationStopped()

public function isPropagationStopped(): bool;

Returns true when the event must stop propagating to subsequent listeners.

Contracts\Events\Subscriber

Interface Source on GitHub

Contract for event subscriber classes. A subscriber declares the events it wants to listen to via a static map; Events\Manager parses the map and attaches each entry as a regular listener.

Accepted value shapes per event key:

'event:name' => 'methodName' 'event:name' => ['methodName', priority] 'event:name' => [ ['methodName1'], ['methodName2', priority], ]

Keys can be either a Phalcon event string (e.g. "db:beforeQuery") or a fully qualified event class name.

Wildcard subscriptions: Phalcon's manager fires both the prefix queue and the full-name queue (e.g. "db" is fired before "db:beforeQuery"). To subscribe to every event of a component, use the prefix as the key:

'db' => 'onAnyDbEvent' // fires for db:beforeQuery, db:afterQuery, ...

  • Phalcon\Contracts\Events\Subscriber

Method Summary

Methods

Public · 1

getSubscribedEvents()

public static function getSubscribedEvents(): array;

Returns a map of event name => listener config. Called once per Manager::addSubscriber() / removeSubscriber() call.

Contracts\Filter\Sanitizer

Interface Source on GitHub

The contract for sanitizers registered in Phalcon\Filter\Filter.

A sanitizer is an invokable object: it must expose a public __invoke() method that receives the value to sanitize as its first parameter and returns the sanitized value. Additional parameters, when a sanitizer needs them (e.g. regex, replace), must be declared after the value parameter; Phalcon\Filter\Filter::sanitize() forwards them in order.

__invoke() is intentionally not declared here: implementations type their value parameter differently (string for text-only sanitizers, untyped for coercing ones), and PHP parameter variance does not allow an implementation to narrow a parameter declared by an interface.

A sanitizer operates on a single value. Array handling (one level of recursion by default) is the responsibility of Phalcon\Filter\Filter::sanitize(), not of the sanitizer.

  • Phalcon\Contracts\Filter\Sanitizer

Contracts\Flash\Flash

Interface Source on GitHub

Canonical contract for Phalcon\Flash messengers.

Note: output() and clear() are part of the concrete Direct / Session API and are not declared on this contract; they are scheduled to be added in the next major version.

Method Summary

Methods

Public · 5

error()

public function error( string $message ): string|null;

Shows a HTML error message

message()

public function message(
    string $type,
    string $message
): string|null;

Outputs a message

Note: the shipped implementations (Direct, Session) accept string|array for $message; this contract declares string and is scheduled to be widened to mixed in the next major version. Delivery semantics differ per implementation: Direct::message() renders and emits the message immediately, while Session::message() stores the raw message for output on a later request.

notice()

public function notice( string $message ): string|null;

Shows a HTML notice/information message

success()

public function success( string $message ): string|null;

Shows a HTML success message

warning()

public function warning( string $message ): string|null;

Shows a HTML warning message

Contracts\Forms\Schema

Interface Source on GitHub

Contract for objects that supply a normalized list of form element definitions. Implementations may source the definitions from a PHP array, a JSON document, a YAML file, or any other format.

Each returned definition must be an associative array containing at least: - 'type' (string) - element type key (e.g. 'text', 'select', 'checkgroup') - 'name' (string) - the HTML name attribute value

Optional keys per definition: - 'label' (string) - visible label text - 'default' (mixed) - pre-populated default value - 'attributes' (array) - additional HTML attributes - 'filters' (array|string) - filter names applied on bind() - 'validators' (array) - ValidatorInterface instances - 'options' (array) - choices for select / checkgroup / radiogroup

  • Phalcon\Contracts\Forms\Schema

Method Summary

Methods

Public · 1

load()

public function load(): array;

Returns an ordered list of normalized element definitions.

Contracts\Html\Helper\Input\SelectData

Interface Source on GitHub

Interface for SELECT option data providers.

Return format: [value => label] for flat options; [groupLabel => [value => label, ...]] for optgroups.

  • Phalcon\Contracts\Html\Helper\Input\SelectData

Method Summary

Methods

Public · 2

getAttributes()

public function getAttributes(): array;

Returns the per-option attribute map.

Format: [optionValue => [attrName => stringValue, ...]]. Implementations must return resolved string values; no escaping, ordering, or rendering is performed here.

getOptions()

public function getOptions(): array;

Contracts\Logger\Adapter\Adapter

Interface Source on GitHub

Canonical contract for Phalcon\Logger adapters.

Uses Phalcon\Logger\Formatter\FormatterInterface · Phalcon\Logger\Item

Method Summary

Methods

Public · 9

add()

public function add( Item $item ): Adapter;

Adds a message in the queue

begin()

public function begin(): Adapter;

Starts a transaction

close()

public function close(): bool;

Closes the logger

commit()

public function commit(): Adapter;

Commits the internal transaction

getFormatter()

public function getFormatter(): FormatterInterface;

Returns the internal formatter

inTransaction()

public function inTransaction(): bool;

Returns the whether the logger is currently in an active transaction or not

process()

public function process( Item $item ): void;

Processes the message in the adapter

rollback()

public function rollback(): Adapter;

Rollbacks the internal transaction

setFormatter()

public function setFormatter( FormatterInterface $formatter ): Adapter;

Sets the message formatter

Contracts\Logger\Formatter\Formatter

Interface Source on GitHub

Canonical contract for Phalcon\Logger formatters.

Uses Phalcon\Logger\Item

Method Summary

Methods

Public · 1

format()

public function format( Item $item ): string;

Applies a format to an item

Contracts\Logger\Logger

Interface Source on GitHub

Canonical contract for Phalcon\Logger\Logger.

Uses Phalcon\Contracts\Logger\Adapter\Adapter

Method Summary

Methods

Public · 14

alert()

public function alert(
    string $message,
    array $context = []
): void;

Action must be taken immediately.

Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

critical()

public function critical(
    string $message,
    array $context = []
): void;

Critical conditions.

Example: Application component unavailable, unexpected exception.

debug()

public function debug(
    string $message,
    array $context = []
): void;

Detailed debug information.

emergency()

public function emergency(
    string $message,
    array $context = []
): void;

System is unusable.

error()

public function error(
    string $message,
    array $context = []
): void;

Runtime errors that do not require immediate action but should typically be logged and monitored.

getAdapter()

public function getAdapter( string $name ): Adapter;

Returns an adapter from the stack

getAdapters()

public function getAdapters(): array;

Returns the adapter stack array

getLogLevel()

public function getLogLevel(): int;

Returns the log level

getName()

public function getName(): string;

Returns the name of the logger

info()

public function info(
    string $message,
    array $context = []
): void;

Interesting events.

Example: User logs in, SQL logs.

log()

public function log(
    mixed $level,
    string $message,
    array $context = []
): void;

Logs with an arbitrary level.

An unknown level (a typo or an unmapped value) is not rejected; it maps to the CUSTOM level and is logged, rather than raising an exception.

notice()

public function notice(
    string $message,
    array $context = []
): void;

Normal but significant events.

trace()

public function trace(
    string $message,
    array $context = []
): void;

Extra-verbose diagnostic output.

warning()

public function warning(
    string $message,
    array $context = []
): void;

Exceptional occurrences that are not errors.

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

Contracts\Messages\Messages

Interface Source on GitHub

Canonical contract for Phalcon\Messages\Messages.

The collection stores Phalcon\Messages\MessageInterface objects and is iterated by integer position. An entry added under a string key through the ArrayAccess interface stays reachable by that offset but is not visited during iteration (foreach), which walks the integer sequence only.

  • ArrayAccess
    • Phalcon\Contracts\Messages\Messages — extends ArrayAccess, Countable, Iterator

Uses ArrayAccess · Countable · Iterator · Phalcon\Messages\MessageInterface

Method Summary

Methods

Public · 3

appendMessage()

public function appendMessage( MessageInterface $message ): void;

Appends a message to the collection

appendMessages()

public function appendMessages( mixed $messages );

Appends an array of messages to the collection

filter()

public function filter( string $fieldName ): array;

Filters the message collection by field name

Contracts\Mvc\Dispatcher

Interface Source on GitHub

Canonical contract for Phalcon\Mvc\Dispatcher.

Uses Phalcon\Contracts\Dispatcher\Dispatcher · Phalcon\Mvc\ControllerInterface

Method Summary

Methods

Public · 6

getActiveController()

public function getActiveController(): ControllerInterface|null;

Returns the active controller in the dispatcher

getControllerName()

public function getControllerName(): string;

Gets last dispatched controller name

getLastController()

public function getLastController(): ControllerInterface|null;

Returns the latest dispatched controller

setControllerName()

public function setControllerName( string $controllerName ): DispatcherContract;

Sets the controller name to be dispatched

setControllerSuffix()

public function setControllerSuffix( string $controllerSuffix ): DispatcherContract;

Sets the default controller suffix

setDefaultController()

public function setDefaultController( string $controllerName ): DispatcherContract;

Sets the default controller name

Contracts\Mvc\Model\Relation\CacheKeyProvider

Interface Source on GitHub

Interface for models that provide a custom unique key for the reusable records cache in the Model Manager. Implement this interface when the default object-identity based key (unique_key) does not produce stable cache hits across multiple object instances that represent the same database record.

  • Phalcon\Contracts\Mvc\Model\Relation\CacheKeyProvider

Method Summary

Methods

Public · 1

getUniqueKey()

public function getUniqueKey(): string;

Returns a string that uniquely identifies this model instance for use as the key in the reusable records cache.

Contracts\Paginator\Adapter

Interface Source on GitHub

Interface for Phalcon\Paginator adapters

Method Summary

Methods

Public · 4

getLimit()

public function getLimit(): int;

Get current rows limit

paginate()

public function paginate(): Repository;

Returns a slice of the resultset to show in the pagination

setCurrentPage()

public function setCurrentPage( int $page ): Adapter;

Set the current page number

setLimit()

public function setLimit( int $limit ): Adapter;

Set current rows limit

Contracts\Paginator\Repository

Interface Source on GitHub

Interface for the repository of current state Phalcon\Paginator\AdapterInterface::paginate()

Two adapter dialects fill this repository:

  • Offset adapters (Model, NativeArray, QueryBuilder) populate every property as a sequential page number / item count.
  • Cursor adapters (QueryBuilderCursor) reuse the same properties with a different meaning: getCurrent()/getNext() carry keyset cursor values rather than page numbers, and getTotalItems(), getLast() and getPrevious() are not computed (they return 0).

Method Summary

Constants

string PROPERTY_CURRENT_PAGE = "current"
string PROPERTY_FIRST_PAGE = "first"
string PROPERTY_ITEMS = "items"
string PROPERTY_LAST_PAGE = "last"
string PROPERTY_LIMIT = "limit"
string PROPERTY_NEXT_PAGE = "next"
string PROPERTY_PREVIOUS_PAGE = "previous"
string PROPERTY_TOTAL_ITEMS = "total_items"

Methods

Public · 11

getAliases()

public function getAliases(): array;

Gets the aliases for properties repository

getCurrent()

public function getCurrent(): int;

Gets number of the current page

Cursor adapters store the cursor value used for the current page here (0 on the first page), not a sequential page number.

getFirst()

public function getFirst(): int;

Gets number of the first page

getItems()

public function getItems(): mixed;

Gets the items on the current page

getLast()

public function getLast(): int;

Gets number of the last page

Cursor adapters do not compute this and return 0.

getLimit()

public function getLimit(): int;

Gets current rows limit

getNext()

public function getNext(): int;

Gets number of the next page

Cursor adapters store the next cursor value here rather than a page number; 0 means there is no next page.

getPrevious()

public function getPrevious(): int;

Gets number of the previous page

Cursor adapters do not compute this and return 0.

getTotalItems()

public function getTotalItems(): int;

Gets the total number of items

Cursor adapters do not compute this and return 0.

setAliases()

public function setAliases( array $aliases ): Repository;

Sets the aliases for properties repository

setProperties()

public function setProperties( array $properties ): Repository;

Sets values for properties of the repository

Contracts\Support\Collection

Interface Source on GitHub

Canonical contract for Phalcon\Support\Collection.

@extends ArrayAccess @extends IteratorAggregate

Uses ArrayAccess · IteratorAggregate

Method Summary

public mixed __get( string $element ) public bool __isset( string $element ) public void __set(string $element,mixed $value) public void __unset( string $element ) public void clear() Clears the internal collection. public array column( string $propertyOrMethod ) Returns the values from a single property/method extracted from every public static each( callable $callback ) Invokes the callback for every item in the collection. public static filter( callable $callback ) Returns a new collection of items for which the callback returns true. public mixed first() Returns the first value in the collection or null when empty. public mixed get(string $element,mixed $defaultValue = null,string $cast = null) Returns an element from the collection. public array getKeys( bool $insensitive = true ) Returns the keys (insensitive or not) of the collection. public string|null getType() Returns the configured runtime type guard, or null when not set. public array getValues() Returns the values of the internal array. public bool has( string $element ) Checks whether an element exists in the collection. public void init( array $data = [] ) Initializes the internal array. public bool isEmpty() Returns true when the collection has no entries. public array keys( bool $insensitive = true ) Returns the keys (insensitive or not) of the collection. public mixed last() Returns the last value in the collection or null when empty. public static map( callable $callback ) Returns a new collection with the callback applied to every value. public mixed reduce(callable $callback,mixed $initial = null) Reduces the collection to a single value using the callback. public void remove( string $element ) Removes the element from the collection. public void replace( array $data ) Replaces the collection data with a new array, clearing first. public void set(string $element,mixed $value) Stores an element in the collection. public static sort(callable $callback = null,int $order = 4) Returns a new collection sorted by value, preserving keys. public array toArray() Returns the collection as an array. public string toJson( int $options = 4194383 ) Returns the collection serialized as a JSON string. public array values() Returns the values of the internal array. public static where(string $propertyOrMethod,mixed $value) Returns a new collection containing only the items whose

Methods

Public · 28

__get()

public function __get( string $element ): mixed;

__isset()

public function __isset( string $element ): bool;

__set()

public function __set(
    string $element,
    mixed $value
): void;

__unset()

public function __unset( string $element ): void;

clear()

public function clear(): void;

Clears the internal collection.

column()

public function column( string $propertyOrMethod ): array;

Returns the values from a single property/method extracted from every item in the collection, keyed by the original collection key.

each()

public function each( callable $callback ): static;

Invokes the callback for every item in the collection.

filter()

public function filter( callable $callback ): static;

Returns a new collection of items for which the callback returns true.

first()

public function first(): mixed;

Returns the first value in the collection or null when empty.

get()

public function get(
    string $element,
    mixed $defaultValue = null,
    string $cast = null
): mixed;

Returns an element from the collection.

getKeys()

public function getKeys( bool $insensitive = true ): array;

Returns the keys (insensitive or not) of the collection.

getType()

public function getType(): string|null;

Returns the configured runtime type guard, or null when not set.

getValues()

public function getValues(): array;

Returns the values of the internal array.

has()

public function has( string $element ): bool;

Checks whether an element exists in the collection.

init()

public function init( array $data = [] ): void;

Initializes the internal array.

isEmpty()

public function isEmpty(): bool;

Returns true when the collection has no entries.

keys()

public function keys( bool $insensitive = true ): array;

Returns the keys (insensitive or not) of the collection.

last()

public function last(): mixed;

Returns the last value in the collection or null when empty.

map()

public function map( callable $callback ): static;

Returns a new collection with the callback applied to every value.

reduce()

public function reduce(
    callable $callback,
    mixed $initial = null
): mixed;

Reduces the collection to a single value using the callback.

remove()

public function remove( string $element ): void;

Removes the element from the collection.

replace()

public function replace( array $data ): void;

Replaces the collection data with a new array, clearing first.

set()

public function set(
    string $element,
    mixed $value
): void;

Stores an element in the collection.

sort()

public function sort(
    callable $callback = null,
    int $order = 4
): static;

Returns a new collection sorted by value, preserving keys.

toArray()

public function toArray(): array;

Returns the collection as an array.

toJson()

public function toJson( int $options = 4194383 ): string;

Returns the collection serialized as a JSON string.

values()

public function values(): array;

Returns the values of the internal array.

where()

public function where(
    string $propertyOrMethod,
    mixed $value
): static;

Returns a new collection containing only the items whose propertyOrMethod strictly equals $value.