layout | title | keywords |
---|---|---|
default |
Upgrade Guide |
upgrade, v3, v4, v5 |
![](/assets/images/version-{{ pageVersion }}.svg)
So you have decided to upgrade to v5! Congratulations!!
Phalcon v5 contains a lot of changes in components and interfaces. Upgrading is going to be a time-consuming task, depending on how big and complex your application is. We hope that this document will make your upgrade journey smoother and also offer insight as to why certain changes were made and how it will help the framework in the future.
We will outline the areas that you need to pay attention to and make necessary changes so that your code can run as smoothly as it has been with v4. Although the changes are significant, it is more of a methodical task than a daunting one.
Phalcon v5 supports only PHP 7.4 and above. PHP 7.4 active support expired roughly a month before the release of Phalcon 5, but support for security patches etc. will continue until November 2022. After that time, we will drop support for PHP 7.4 also.
Since Phalcon 4, we have been following the PHP releases and adjusting Phalcon accordingly to work with those releases.
Phalcon can be installed using PECL.
pecl install phalcon
// pecl install phalcon-5.3.0
Alternative installation
Download the latest zephir.phar
from here. Add it to a folder that can be accessed by your system.
Clone the repository
git clone https://github.com/phalcon/cphalcon
Compile Phalcon
cd cphalcon/
git checkout tags/5.3.0 ./
zephir fullclean
zephir build
You will need to add the following line to your php.ini
(in some cases both the CLI and web versions of it)
extension=phalcon.so
Check the module
php -m | grep phalcon
If the above does not work, check the php.ini
that your CLI is looking for. If you are using phpinfo()
and a web browser to check if Phalcon has been loaded, make sure that your php.ini
file that your web server is looking for contains the extension=phalcon.so
. You will need to restart your web server after you added the new line in php.ini
.
One of the biggest changes with this release is that we no longer have top level classes. All top level classes have been moved into relevant namespaces (except Phalcon\Tag
). For instance Phalcon\Loader
has been moved to Phalcon\Autoload\Loader
. This change was necessary for the future expansion of the project.
Summary
v4 | v5 |
---|---|
Phalcon\Cache |
Phalcon\Cache\Cache |
Phalcon\Collection |
Phalcon\Support\Collection |
Phalcon\Config |
Phalcon\Config\Config |
Phalcon\Container |
Phalcon\Container\Container |
Phalcon\Crypt |
Phalcon\Encryption\Crypt |
Phalcon\Debug |
Phalcon\Support\Debug |
Phalcon\Di |
Phalcon\Di\Di |
Phalcon\Escaper |
Phalcon\Html\Escaper |
Phalcon\Exception |
Removed |
Phalcon\Filter |
Phalcon\Filter\Filter |
Phalcon\Helper |
Removed in favor of Phalcon\Support\Helper |
Phalcon\Loader |
Phalcon\Autoload\Loader |
Phalcon\Logger |
Phalcon\Logger\Logger |
Phalcon\Kernel |
Removed |
Phalcon\Registry |
Phalcon\Support\Registry |
Phalcon\Security |
Phalcon\Encryption\Security |
Phalcon\Text |
Removed in favor of Phalcon\Support\Helper |
Phalcon\Url |
Phalcon\Mvc\Url |
Phalcon\Validation |
Phalcon\Filter\Validation |
Phalcon\Version |
Phalcon\Support\Version |
The ACL component has had some methods and components renamed. The functionality remains the same as in previous versions.
- Renamed
Phalcon\Acl\ComponentAware
toPhalcon\Acl\ComponentAwareInterface
- Renamed
Phalcon\Acl\RoleAware
toPhalcon\Acl\RoleAwareInterface
- Added
getInheritedRoles()
to return an array of the inherited roles in the adapter.
- The
getEventsManager()
now returns aPhalcon\Events\ManagerInterface
ornull
The Assets component has had changes to the interface as well as some methods were renamed. The functionality remains the same as in previous versions.
getAssetKey()
now usessha256
to compute the key- Renamed
getLocal()
toisLocal()
- Renamed
setLocal()
tosetIsLocal()
- The class now uses
ArrayIterator
instead ofIterator
- Renamed
getLocal()
toisLocal()
- Renamed
setLocal()
tosetIsLocal()
- Renamed
getTargetLocal()
togetTargetIsLocal()
- Renamed
setTargetLocal()
tosetTargetIsLocal()
- Removed
getPosition()
,current()
,key()
,next()
,rewind()
,valid()
getAssetKey()
now usessha256
to compute the key
__construct()
requires aPhalcon\Html\TagFactory
as the first parameter
public function __construct(Phalcon\Html\TagFactory $tagFactory, array $options = [])
addCss()
now requires$local
to bebool
and$attributes
to be an array
public function addCss(
string $path,
bool $local = true,
bool $filter = true,
array $attributes = [],
string $version = null,
bool $autoVersion = false
): Manager
addInlineCss()
now requires$filter
to bebool
and$attributes
to be an array
public function addInlineCss(
string $content,
bool $filter = true,
array $attributes = []
): Manager
addJs()
now requires$local
to bebool
and$attributes
to be an array
public function addJs(
string $path,
bool $local = true,
bool $filter = true,
array $attributes = [],
string $version = null,
bool $autoVersion = false
): Manager
addInlineJs()
now requires$filter
to bebool
and$attributes
to be an array
public function addInlineJs(
string $content,
bool $filter = true,
array $attributes = []
): Manager
- Added
has()
method to return if a collection exists
The Autoload\Loader component has been moved from the parent namespace. Some method names have been changed and new functionality introduced.
__construct(bool $isDebug = false)
The constructor now accepts a boolean, which allows the loader to collect and store debug information during the discovery and loading process of files, classes etc. If the variable is set totrue
,getDebug()
will return an array with all the debugging information during the autoload operation. This mode is only for debugging purposes and must not be used in production environments.
use Phalcon\Autoload\Loader;
use Adapter\Another;
$loader = new Loader(true);
$loader
->addNamespace('Base', './Namespaces/Base/')
->addNamespace('Adapter', './Namespaces/Adapter/')
->addNamespace('Namespaces', './Namespaces/')
;
$loader->autoload(Another::class);
var_dump($loader->getDebug());
// [
// 'Loading: Adapter\Another',
// 'Class: 404: Adapter\Another',
// 'Require: 404: ./Namespaces/Adapter/Another.php',
// 'Require: ./Namespaces/Another.php',
// 'Namespace: Namespaces\Adapter - ./Namespaces/Another.php',
// ];
add*
methods have been introduced to help with the setup of the autoloaderaddClass(string $name, string $file): Loader
addDirectory(string $directory): Loader
addExtension(string $extension): Loader
addFile(string $file): Loader
addNamespace(string $name, string|array $directories, bool $prepend = false): Loader
getCheckedPath()
now returns either a string or anull
(if not populated yet)getDebug()
returns an array of debug information, if the Loader has been instantiated with$isDebug = true
getDirs()
has been renamed togetDirectories()
getFoundPath()
now returns either a string or anull
(if not populated yet)registerClasses()
has been renamed tosetClasses()
registerDirs()
has been renamed tosetDirectories()
registerExtensions()
has been renamed tosetExtensions()
setExtensions()
now accepts a second parameter (bool
$merge
) which allows you to merge the data set with what is already set in the LoaderregisterFiles()
has been renamed tosetFiles()
registerNamespaces()
has been renamed tosetNamespaces()
The Cache component has been moved to the Cache
namespace.
- The constructor now requires a
Phalcon\Storage\SerializerFactory
to be passed as the first parameter - The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
- Moved
Phalcon\Cache
toPhalcon\Cache\Cache
- The component has been refactored and the dependency to
PSR
has been removed. more
- A new interface has been introduced (
Phalcon\Cache\CacheInterface
) to offer more flexibility when extending the cache object.
The Collection component has been moved to the Support
namespace. more
The Config component has been moved to the Config
namespace.
- Moved
Phalcon\Config
toPhalcon\Config\Config
- A new interface has been introduced (
Phalcon\Config\ConfigInterface
) to offer more flexibility when extending the config object.
The Container
component has been removed from the framework. It is in our roadmap to develop a new container that will support auto wiring, as well as providers. Additionally, the container will be designed and implemented in such a way that could be used as a PSR-11 container (with the help of a Proxy class).
The Crypt component has been moved to the Encryption
namespace. more
- Changed
connect(array descriptor = null): bool
toconnect(array descriptor = []): void
- Changed
execute(string $sqlStatement, $bindParams = null, $bindTypes = null): bool
toexecute(string $sqlStatement, array $bindParams = [], array $bindTypes = []) -> bool
- Changed
getErrorInfo()
togetErrorInfo(): array
- Changed
getInternalHandler(): \PDO
togetInternalHandler(): mixed
- Changed
lastInsertId($sequenceName = null): int | bool
tolastInsertId(string $name = null) -> string | bool
- Changed
query(string $sqlStatement, $bindParams = null, $bindTypes = null): ResultInterface | bool
toquery(string $sqlStatement, array $bindParams = [], array $bindTypes = []): ResultInterface | bool
- Changed bind type for
Column::TYPE_BIGINT
to beColumn::BIND_PARAM_STR
- Added bind type for
Column::TYPE_BINARY
to cater forVARBINARY
andBINARY
fields - Added support for comments
- Changed bind type for
Column::TYPE_BIGINT
to beColumn::BIND_PARAM_STR
- Added support for comments
- Changed property
connectionId
toint
- Added property
realSqlStatement
to store the real SQL statement executed - Changed
delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool
todelete($table, string $whereCondition = null, array $placeholders = [], array $dataTypes = []): bool
- Changed
fetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array
tofetchAll(string $sqlQuery, int $fetchMode = Enum::FETCH_ASSOC, array $bindParams = [], array $bindTypes = []): array
- Changed
fetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, $bindParams = null, $bindTypes = null): array
tofetchOne(string $sqlQuery, $fetchMode = Enum::FETCH_ASSOC, array $bindParams = [], array $bindTypes = []): array
- Changed
getEventsManager(): ManagerInterface
togetEventsManager(): ManagerInterface | null
- Added
getSQLVariables(): array
to return the SQL variables used - Added
supportsDefaultValue(): bool
to allow checking for adapters that support theDEFAULT
keyword
- Changed
close(): bool
toclose(): void
- Changed
connect(array $descriptor = null): bool
toconnect(array $descriptor = []): void
- Changed
delete($table, $whereCondition = null, $placeholders = null, $dataTypes = null): bool
todelete($table, string $whereCondition = null, array $placeholders = [], array $dataTypes = []): bool
- Changed
execute(string $sqlStatement, $placeholders = null, $dataTypes = null): bool
toexecute(string $sqlStatement, array $bindParams = [], array $bindTypes = []): bool
- Changed
fetchAll(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array
tofetchAll(string $sqlQuery, int $fetchMode = 2, array $bindParams = [], array $bindTypes = []): array
- Changed
fetchOne(string $sqlQuery, int $fetchMode = 2, $placeholders = null): array;
tofetchOne(string $sqlQuery, int $fetchMode = 2, array $bindParams = [], array $bindTypes = []): array
- Added
getDefaultValue(): RawValue
- Changed
getInternalHandler(): \PDO
togetInternalHandler(): mixed
- Changed
lastInsertId($sequenceName = null): int | bool
tolastInsertId(string $name = null) -> string | bool
- Changed
query(string $sqlStatement, $bindParams = null, $bindTypes = null): ResultInterface | bool
toquery(string $sqlStatement, array $bindParams = [], array $bindTypes = []): ResultInterface | bool
- Added
supportsDefaultValue(): bool
- Added
getExceptionClass()
to return the exception class for the factory - Renamed
getAdapters()
togetServices()
- Added support for comments
- Added support for
SMALLINT
for Postgresql
- Renamed
Phalcon\Db\Result\Pdo
toPhalcon\Db\Result\ResultPdo
- Added support for comments
- Added
TYPE_BINARY
constant - Added
TYPE_VARBINARY
constant - Added
getComment(): string | null
- Changed
getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string;
togetSqlExpression(array $expression, string $escapeChar = null, array $bindCounts = []): string
- Changed
getColumnList(array $columnList, string $escapeChar = null, $bindCounts = null): string
togetColumnList(array $columnList, string $escapeChar = null, array $bindCounts = []): string
- Changed
getSqlColumn($column, string $escapeChar = null, $bindCounts = null): string
togetSqlColumn($column, string $escapeChar = null, array $bindCounts = []): string
- Changed
getSqlExpression(array $expression, string $escapeChar = null, $bindCounts = null): string;
togetSqlExpression(array $expression, string $escapeChar = null, array $bindCounts = []): string
- Changed
Phalcon\Db\Exception
to extend\Exception
- Changed
Phalcon\Db\Profiler
to usehrtime()
internally to calculate metrics
- Changed
dataSeek(long $number)
todataseek(int $number)
The Debug component has been moved to the Support
namespace. more
The Di component has been moved to the Di
namespace.
- Moved
Phalcon\Di
toPhalcon\Di\Di
- The
tag
service now returns an instance ofPhalcon\Html\TagFactory
- The (new)
helper
service returns an instance ofPhalcon\Support\HelperFactory
- Changed
getEventsManager(): ManagerInterface
togetEventsManager(): ManagerInterface | null
- Changed
Phalcon\Dispatcher\Exception
to extend\Exception
- Moved
Phalcon\Crypt
toPhalcon\Encryption\Crypt
- Two new constants introduced
DEFAULT_ALGORITHM = "sha256"
andDEFAULT_CIPHER = "aes-256-cfb"
- The
__construct
now setsuseSigning
astrue
(previouslyfalse
) - The
__construct
accepts a third parameter (null
by default), which is aPhalcon\Encryption\Crypt\PadFactory
use Phalcon\Encryption\Crypt;
use Phalcon\Encryption\Crypt\PadFactory;
$padFactory = new PadFactory();
$crypt = new Crypt("aes-256-cfb", true, $padFactory);
If no padFactory
is passed, a new one will be created in the component.
Phalcon\Encryption\Crypt::getAvailableHashAlgos()
was renamed toPhalcon\Encryption\Crypt::getAvailableHashAlgorithms()
Phalcon\Encryption\Crypt::getHashAlgo()
was renamed toPhalcon\Encryption\Crypt::getHashAlgorithm()
Phalcon\Encryption\Crypt::setHashAlgo()
was renamed toPhalcon\Encryption\Crypt::setHashAlgorithm()
- Moved
Phalcon\Crypt\CryptInterface
toPhalcon\Encryption\Crypt\CryptInterface
- Changed
Phalcon\Encryption\Crypt\CryptInterface::decryptBase64()
to accept astring
variable as thekey
- Changed
Phalcon\Encryption\Crypt\CryptInterface::encryptBase64()
to accept astring
variable as thekey
- Added
Phalcon\Encryption\Crypt\CryptInterface::useSigning(bool useSigning)
- Moved
Phalcon\Crypt\Exception
toPhalcon\Encryption\Crypt\Exception\Exception
- Moved
Phalcon\Crypt\Mismatch
toPhalcon\Encryption\Crypt\Exception\Mismatch
- Moved from
Phalcon\Crypt
- Added
Phalcon\Encryption\PadFactory
to allow for different padding schemes during encryption and decryption of data
- Added
Phalcon\Encryption\Padding\PadInterface
to allow for custom padding classes - Added
Phalcon\Encryption\Padding\Ansi
- Added
Phalcon\Encryption\Padding\Iso10126
- Added
Phalcon\Encryption\Padding\IsoIek
- Added
Phalcon\Encryption\Padding\Noop
- Added
Phalcon\Encryption\Padding\Pkcs7
- Added
Phalcon\Encryption\Padding\Space
- Added
Phalcon\Encryption\Padding\Zero
The Escaper component has been moved to the Html
namespace. more
- Added abstract
Phalcon\Events\AbstractEventsAware
- Changed
public function __construct(string $type, object $source, $data = null, bool $cancelable = true)
to__construct(string $type, $source = null, $data = null, bool $cancelable = true)
($source
is now nullable)
- Changed
Phalcon\Events\Exception
to extend\Exception
- Added
isValidHandler(): bool
to return if the internal handler is valid or not
The class has been removed.
- Added abstract
Phalcon\Factory\AbstractConfigFactory
to check configuration elements
- Changed
init()
to read fromgetServices()
- Changed
Phalcon\Factory\Exception
to extend\Exception
The Filter component has been moved to the Filter
namespace.
- Moved
Phalcon\Filter
toPhalcon\Filter\Filter
- Changed
Phalcon\Filter\Exception
to extend\Exception
- Changed
getAdapters()
togetServices()
- Added
__call()
to allow using filter names as methods i.e.$filter->upper($input)
- Added
getValueByEntity()
andgetValueByData()
for more options to retrieve data
- Changed
Phalcon\Filter\Validation\Validator\Exception
to extend\Exception
- Added the ability to define
allowEmpty
to any validator (in the parameters)
- Changed
Phalcon\Filter\Validation\Exception
to extend\Exception
- Changed
add(string $field, ValidatorInterface $validator): <ValidationInterface
toadd($field, ValidatorInterface $validator): <ValidationInterface
- Changed
rule(string $field, ValidatorInterface $validator): <ValidationInterface
torule($field, ValidatorInterface $validator): <ValidationInterface
- Changed
getAdapters()
togetServices()
- Added the ability to define CSS icon classes (
setCssIconClasses()
) - Changed
getTemplate(string $cssClasses): string
togetTemplate(string $cssClasses, string $cssIconClasses): string
- Changed
Phalcon\Flash\Exception
to extend\Exception
- Added
SESSION_KEY
constant - Changed
has($type = null): bool
tohas(string $type = null): bool
- Changed
message(string $type, string $message): string | null
tomessage(string $type, $message): string | null
Phalcon\Forms\Element\*
classes now use the new Phalcon\Html\TagFactory
to generate HTML code. As a result, the functionality has changed slightly. The main difference is that a Phalcon\Html\TagFactory
has to be set in the form object, so that elements can be rendered. If the Phalcon\Html\TagFactory
is not set, then the component will search the Di container (Phalcon\Di\DiInterface
) for a service with the name tag
. If you are using Phalcon\Di\FactoryDefault
as your container, then the tag
service is already defined for you.
- Added
getTagFactory()
to return thePhalcon\Html\TagFactory
object used internally, as well assetTagFactory(TagFactory $tagFactory): AbstractElement
to set it.
- The classes now use the
Phalcon\Html\Helper\Input\Checkbox
andPhalcon\Html\Helper\Input\Radio
respectively. The classes usechecked
andunchecked
parameters to set the state of each control. If thechecked
parameter is identical to the$value
then the control will be checked. If theunchecked
parameter is present, it will be set if the$value
is not the same as thechecked
parameter. more
The Helper component has been moved to the Support
namespace. more
- Moved
Phalcon\Escaper
toPhalcon\Html\Escaper
- Changed the
flags
property that controls the flags forhtmlspecialchars()
is set to11
which corresponds toENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
. - Method names changed to be more verbose.
- Added
attributes(string input)
for escaping HTML attributes (replacesescapeHtmlAttr()
) - Added
css(string $input)
for escaping CSS (replacesescapeCss()
- Added
html(string $input = null)
for escaping HTML (replacesescapeHtml()
) - Added
js(string $input)
for escaping JS (replacesescapeJs()
) - Added
setFlags(int $flags)
to set the flagshtmlspecialchars()
(replacessetHtmlQuoteType()
) - Added
url(string $input)
for escaping URL strings (replacesescapeUrl()
) escapeCss()
now raises a deprecated warningescapeJs()
now raises a deprecated warningescapeHtml()
now raises a deprecated warningescapeUrl()
now raises a deprecated warningsetHtmlQuoteType()
now raises a deprecated warning
- Added
- Moved
Phalcon\Escaper\EscaperInterface
toPhalcon\Html\Escaper\EscaperInterface
- Added
attributes(string input)
- Added
css(string $input)
- Added
html(string $input = null)
- Added
js(string $input)
- Added
setFlags(int $flags)
- Added
url(string $input)
- Removed
escapeCss()
- Removed
escapeJs()
- Removed
escapeHtml()
- Removed
escapeUrl()
- Removed
setHtmlQuoteType()
- This class has been moved to this namespace
Phalcon\Escaper
. - Changed
Phalcon\Html\Escaper\Exception
to extend\Exception
- Moved
Phalcon\Helper
toPhalcon\Html\Helper
- The component has been refactored and offers more functionality now. more
- The component has been refactored and the dependency to
PSR
has been removed. more
- Added
__call(string $name, array $arguments)
to allow calling helper objects as methods. more - Added
has(string $name) -> bool
Addedset(string $name, mixed $method): void
- The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
- Changed
Phalcon\Html\Exception
to extend\Exception
- Changed
__construct()
and made$httpOnly = false
- Changed
Phalcon\Http\Request\Exception
to extend\Exception
- The namespace has been removed
- Added
getPreferredIsoLocaleVariant(): string
to return the preferred ISO locale variant.
- Changed
Phalcon\Http\Cookie\Exception
to extend\Exception
- Added
isSent(): bool
to return if the cookie has been sent or not
- Added
isSent(): bool
to return if the headers have been sent or not
- Changed
Phalcon\Http\Response\Exception
to extend\Exception
- The namespace has been removed
The class has been moved to the Phalcon\Autoload
namespace more
The Logger component has been moved to the Logger
namespace.
- Moved
Phalcon\Logger
toPhalcon\Logger\Logger
- The component has been refactored and the dependency to
PSR
has been removed. more - The interface method calls are much stricter now.
- Added
Phalcon\Logger\AbstractLogger
with common functionality, to be used by packages that wish to alter interfaces to the logger while keeping the same functionality (see proxy-psr3)
- Failing to write to the file will throw a
LogicException
instead ofUnexpectedValueException
- Changed
process(Item $item): string
(previously it returnedarray|string
)
- Changed
format()
to encode JSON with the following options by default:JSON_HEX_TAG
,JSON_HEX_APOS
,JSON_HEX_AMP
,JSON_HEX_QUOT
,JSON_UNESCAPED_SLASHES
,JSON_THROW_ON_ERROR
,
- The constructor now requires a
Phalcon\Storage\SerializerFactory
to be passed as the first parameter - The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
- Changed
Phalcon\Logger\Exception
to extend\Exception
- Changed
__construct(string $message, string $levelName, int $level, DateTimeImmutable $dateTime, array $context = [])
(dateTtime
accepts aDateTimeImmutable
object)
- A new interface has been introduced (
Phalcon\Logger\LoggerInterface
) to offer more flexibility when extending the cache object.
- Changed
Phalcon\Messages\Exception
to extend\Exception
- Changed the methods to accept a
callable
as the$handler
instead of mixeddelete(string $routePattern, callable $handler, string $name = null)
get(string $routePattern, callable $handler, string $name = null)
head(string $routePattern, callable $handler, string $name = null)
map(string $routePattern, callable $handler, string $name = null)
mapVia(string $routePattern, callable $handler, mixed $method, string $name = null)
options(string $routePattern, callable $handler, string $name = null)
patch(string $routePattern, callable $handler, string $name = null)
post(string $routePattern, callable $handler, string $name = null)
put(string $routePattern, callable $handler, string $name = null)
- Changed
Phalcon\Mvc\Micro\Exception
to extend\Exception
Phalcon\Mvc\Model\MetaData\Strategy\Annotations::getMetaData()
will now return a string instead of an integer when encounteringBIGINT
fields
- Changed the constructor to accept an array
__construct(array $options = [])
- Corrected
having()
signaturehaving(string $conditions, array $bindParams = [], array $bindTypes = [])
- Changed
orderBy()
to accept an array or a stringorderBy(array | string $orderBy)
- Changed
current()
to returnmixed
- Added
__serialize()
and__unserialize()
methods
- Changed the constructor to accept
mixed
for$cache
:__construct(mixed $columnMap, mixed $model, mixed $result, mixed $cache = null, bool $keepSnapshots = false)
- Added
__serialize()
and__unserialize()
methods
- Corrected
where()
signaturewhere(string $conditions, mixed $bindParams = null, mixed $bindTypes = null)
- Changed
Phalcon\Mvc\Model\Exception
to extend\Exception
- Changed
$options
parameter to be an array:addBelongsTo(ModelInterface $model, mixed $fields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasMany(ModelInterface $model, mixed $fields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasOne(ModelInterface $model, mixed $fields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasOneThrough(ModelInterface $model, mixed $fields, string $intermediateModel, mixed $intermediateFields, mixed $intermediateReferencedFields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasManyToMany(ModelInterface $model, mixed $fields, string $intermediateModel, mixed $intermediateFields, mixed $intermediateReferencedFields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
- Changed
getModelSchema(ModelInterface $model)
to returnstring
ornull
- Renamed:
existsBelongsTo()
tohasBelongsTo()
existsMany()
tohasHasMany()
existsOne()
tohasHasOne()
existsOneThrough()
tohasHasOneThrough()
existsManyToMany()
tohasHasManyToMany()
- Changed
getEventsManager()
to returnEventManagerInterface
ornull
- Changed
getModelSchema(ModelInterface $model)
to returnstring
ornull
- Changed
$options
parameter to be an array:addBelongsTo(ModelInterface $model, mixed $fields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasMany(ModelInterface $model, mixed $fields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasOne(ModelInterface $model, mixed $fields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasOneThrough(ModelInterface $model, mixed $fields, string $intermediateModel, mixed $intermediateFields, mixed $intermediateReferencedFields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
addHasManyToMany(ModelInterface $model, mixed $fields, string $intermediateModel, mixed $intermediateFields, mixed $intermediateReferencedFields, string $referencedModel, mixed $referencedFields, array options = []): RelationInterface
- Marked as
@deprecated
:existsBelongsTo()
existsMany()
existsOne()
existsOneThrough()
existsManyToMany()
- Added (replacing the
exists*
methods):hasBelongsTo()
hasHasMany()
hasHasOne()
hasHasOneThrough()
hasHasManyToMany()
- Added
getBuilder()
to return the builder that was created withcreateBuilder()
(ornull
)
getCache()
now returnsnull
or an object (mixed
)
__construct()
accepts an object in the$cache
parameter. The object has implementPhalcon\Cache\CacheInterface
orPsr\SimpleCache\CacheInterface
getCache()
now returnsnull
or an object (mixed
)
- Changed
add()
,addConnect()
,addDelete()
,addGet()
,addHead()
,addOptions()
,addPatch()
,addPost()
,addPurge()
,addPut()
,addTrace()
,attach()
to acceptint
as$position
- Changed
getEventsManager()
to returnManagerInterface
ornull
- Changed
add()
,addConnect()
,addDelete()
,addGet()
,addHead()
,addOptions()
,addPatch()
,addPost()
,addPurge()
,addPut()
,addTrace()
,attach()
to acceptint
as$position
- Changed
Phalcon\Mvc\Router\Exception
to extend\Exception
getHostname()
now returnsstring
ornull
getName()
now returnsstring
ornull
beforeMatch(callable $callback): RouteInterface
now accepts acallable
getHostname()
now returnsstring
ornull
getName()
now returnsstring
ornull
- Changed
average(array $parameters = [])
to accept an array - Changed
cloneResultset()
to defaultkeepSnapshots = false
- Changed
findFirst(mixed $parameters = null): mixed | null
to returnnull
instead offalse
- Changed
getSchema(): string | null
to returnstring
ornull
- Marked as
@deprecated
exists()
- Added
has()
(replacing theexists()
method)
- Changed
Phalcon\Mvc\View\Exception
to extend\Exception
- Removed
compileCache()
- Moved from
Phalcon\Url
- Moved from
Phalcon\Url\Exception
- Changed
Phalcon\Mvc\Url\Exception
to extend\Exception
- Moved from
Phalcon\Url\UrlInterface
- Changed
Phalcon\Paginator\Exception
to extend\Exception
- The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
The Registry component has been moved to the Support
namespace. more
The Security component has been moved to the Encryption
namespace. more
- Changed
gc(int $maxlifetime): int | bool
to accept onlyint
for the parameter
- Changed
gc(int $maxlifetime): int | bool
to accept onlyint
for the parameter
- Changed
__construct()
to throw an exception if the save path is empty
- Added interface for
Phalcon\Session\Bag
- Changed
Phalcon\Session\Exception
to extend\Exception
- Added
setForever(string $key, mixed $value):
to set an item in the store forever
- Added
setForever(string $key, mixed $value):
to set an item in the store forever
- Added
setForever(string $key, mixed $value):
to set an item in the store forever
- Added
setForever(string $key, mixed $value):
to set an item in the store forever
- Added
setForever(string $key, mixed $value):
to set an item in the store forever - Added
timeout
,connectTimeout
,retryInterval
andreadTimeout
for constructor options
- Added
setForever(string $key, mixed $value):
to set an item in the store forever
- Added
__serialize()
and__unserialize()
methods - Added
isSuccess(): bool
to return when the data was serialized/unserialized successfully
- Changed
unserialize
to set the data to an empty string in case of a failure
- Changed
unserialize
to set the data to an empty string in case of a failure
- Changed
unserialize
to set the data to an empty string in case of a failure
- Changed
unserialize
to set the data to an empty string in case of a failure
- Added stub serializers for Memcached and Redis when in need to use the built-in serializers for those storages:
Phalcon\Storage\Serializer\MemcachedIgbinary
Phalcon\Storage\Serializer\MemcachedJson
Phalcon\Storage\Serializer\MemcachedPhp
Phalcon\Storage\Serializer\RedisIgbinary
Phalcon\Storage\Serializer\RedisJson
Phalcon\Storage\Serializer\RedisMsgpack
Phalcon\Storage\Serializer\RedisNone
Phalcon\Storage\Serializer\RedisPhp
- Changed
Phalcon\Storage\Exception
to extend\Exception
- The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
- The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
The Support
namespace contains classes that are used throughout the framework. The classes moved here are:
- Moved
Phalcon\Collection
toPhalcon\Support\Collection
get()
will return thedefaultValue
if thekey
is not set. It will also return thedefaultValue
if thekey
is set and the value isnull
. This aligns with the 3.x behavior.
- A new interface has been introduced (
Phalcon\Support\Collection\CollectionInterface
) to offer more flexibility when extending the collection object.
- This class has been renamed from
ReadOnly
in order to avoid collisions with PHP 8.x reserved words.
- Changed
Phalcon\Support\Debug\Exception
to extend\Exception
- Changed
Phalcon\Support\Helper\Exception
to extend\Exception
Arr
,Fs
,Json
,Number
andStr
static classes have been removed and replaced with one class per method in the relevant namespace. For examplePhalcon\Helper\Arr::has()
is notPhalcon\Support\Helper\Arr\Has::__invoke()
- Added
Phalcon\Support\Helper\HelperFactory
service locator to easily create objects from thePhalcon\Support\Helper
namespace - Added
__call()
inPhalcon\Support\Helper\HelperFactory
to offer an easier access to objects i.e.$this->helperFactory->dirFromFile()
Note, this component will be removed in future versions of the framework.
- Added
preload(mixed $parameters): string
to parse preloading link headers
The Phalcon\Text
component has been deprecated. It has been replaced with the Phalcon\Support\HelperFactory
. more
- Changed
__construct(InterpolatorFactory $interpolator, array $options = []
to default to an empty array for$options
- Marked as
@deprecated
exists()
- Added
has()
- Marked as
@deprecated
exists()
- Added
has()
- Marked as
@deprecated
exists()
- Added
has()
- Added
toArray()
to return the translation array back
- Changed
Phalcon\Translate\Exception
to extend\Exception
- The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
- The
getAdapters()
protected method has been renamed togetServices()
- A new protected method
getExceptionClass()
was introduced to return the exception class to throw from this factory when necessary
The Url component has been moved to the Mvc
namespace. more
The Validation component has been moved to the Filter
namespace. more
The Version component has been moved to the Support
namespace. more
Since the tag
service has changed from Phalcon\Tag
to Phalcon\Html\TagFactory
several helper methods used in Volt have changed also. The biggest change is the form()
helper in Volt.
If you wish to keep your Volt code the way it is, without changing method signatures, you will have to rename your form()
calls to formLegacy()
. formLegacy()
will use the Phalcon\Tag
component as before. However, if you wish to use the new Phalcon\Html\TagFactory
component, you can keep the method call as is (i.e. form()
but you will need to change the signature of the helper method. more...