Upgrade & update some class/function from Phalcon 3.4 to 5.0
1
phút đọc
-
Upgrade on base:
- Linux Ubuntu 20.04 LTS
- PHP 8.1
-
In filepath
app/config.php
- Moved
Phalcon\Config
toPhalcon\Config\Config
- Moved
-
In filepath
app/loader.php
-
Moved
Phalcon\Loader
to\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.php
change 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_FOUND
toException::EXCEPTION_HANDLER_NOT_FOUND
anduse Phalcon\Dispatcher\Exception;
-
Moved
PhDispatcher::EXCEPTION_ACTION_NOT_FOUND
toException::EXCEPTION_ACTION_NOT_FOUND
anduse Phalcon\Dispatcher\Exception;
-
-
Moved all
Phalcon\DI
toPhalcon\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]