Upgrade & update some class/function from Phalcon 3.4 to 5.0
-
Upgrade on base:
- Linux Ubuntu 20.04 LTS
- PHP 8.1
-
In filepath
app/config.php- Moved
Phalcon\ConfigtoPhalcon\Config\Config
- Moved
-
In filepath
app/loader.php-
Moved
Phalcon\Loaderto\Phalcon\Autoload\Loader -
Moved
registerDirs()tosetDirectories() -
Moved
registerNamespaces()tosetNamespaces() -
Moved
registerClasses()has been renamed tosetClasses()
-
-
In filepath
app/config/router.php- Moved
$router->handle()to$router->handle($_SERVER['REQUEST_URI'] ?? '/')
- Moved
-
In filepath
public/index.php- Moved
echo $application->handle()->getContent()to$application->handle($_SERVER['REQUEST_URI'] ?? '/')->getContent() - see link [https://github.com/phalcon/cphalcon/issues/14087]
- Moved
-
In filepath
app/config/services.phpchange key off array
instead of
$volt->setOptions([
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_'
]);
update to
$volt->setOptions([
'path' => $config->application->cacheDir,
'separator' => '_'
]);
-
Access to 404 page
-
Moved
PhDispatcher::EXCEPTION_HANDLER_NOT_FOUNDtoException::EXCEPTION_HANDLER_NOT_FOUNDanduse Phalcon\Dispatcher\Exception; -
Moved
PhDispatcher::EXCEPTION_ACTION_NOT_FOUNDtoException::EXCEPTION_ACTION_NOT_FOUNDanduse Phalcon\Dispatcher\Exception;
-
-
Moved all
Phalcon\DItoPhalcon\Di\Di -
Phalcon session error:
$di->set('session', function() use ($di) {
$session = new Phalcon\Session\Manager();
$files = new Phalcon\Session\Adapter\Stream();
$session->setAdapter($files)->start();
return $session;
});
- Phalcon flash error:
/**
* Register the session flash service with the Twitter Bootstrap classes
*/
$di->set('flash', function () {
$flash = new FlashSession();
$flash->setAutomaticHtml(true);
$flash->setCssClasses([
'error' => 'alert alert-danger',
'success' => 'alert alert-success',
'notice' => 'alert alert-info',
'warning' => 'alert alert-warning'
]);
return $flash;
});
see link
- [https://forum.phalcon.io/discussion/20335/phalcon-session-error]
- [https://docs.phalcon.io/5.0/en/upgrade#phalconflashabstractflash]