Upgrading



This guide takes you through the steps needed to migrate from Mako 5.7.x to 6.0.x. You should also take a look at the changelog for a full list of changes to internal classes and methods.


Application configuration

The base_url key of the application config file should be set to null instead of an empty string if the application is using auto-detection.


Authentication

The mako\gatekeeper\Authentication class has been renamed to mako\gatekeeper\Gatekeeper. Any type hints or uses of the class constants must be updated to use the new class name.

The policies key must be added to the app/config/gatekeeper.php config file.


Database

ORM

Support for magic scope methods has been removed. Use the scope method instead.


FileSystem

The following methods that were deprecated in Mako 5.7.0 have been removed:

  • FileSystem::mime()
  • FileSystem::hash()
  • FileSystem::hmac()

The same functionality (and more) can now be found in the FileInfo class.


HTTP

Request

Several of the mako\http\Request methods have been renamed for consistency.

Before Now
basePath getBasePath
baseURL getBaseURL
contentType getContentType
ip getIp
language getLanguage
languagePrefix getLanguagePrefix
method getMethod
password getPassword
path getPath
realMethod getRealMethod
referer getReferrer
scriptName getScriptName
username getUsername

Headers

Several of the mako\http\request\Headers methods have been renamed for consistency.

Before Now
acceptableContentTypes getAcceptableContentTypes
acceptableLanguages getAcceptableLanguages
acceptableCharsets getAcceptableCharsets
acceptableEncodings getAcceptableEncodings

Response

Several of the mako\http\Response methods have been renamed for consistency.

Before Now
body setBody
cache enableCaching
charset setCharset
compression enableCompression
status setStatus
type setType

JSON

The status method of the JSON response builder has been renamed to setStatus.

Redirect

The status method of the Redirect response sender has been renamed to setStatus.

Exceptions

The RequestException has been renamed to HttpException.

Routing

Constraints

Constraint parameters are now injected through the constructor and the Constraint base class has been removed. Constraints should now implement the ConstraintInterface. Check out the documentation for more details.

Middleware

Middleware parameters are now injected through the constructor and the Middleware base class has been removed. Middleware should now implement the MiddlewareInterface. Check out the documentation for more details.


Migrations

The return type of the up and down methods of your migrations must be void.

/**
 * Makes changes to the database structure.
 */
public function up(): void
{

}

/**
 * Reverts the database changes.
 */
public function down(): void
{

}

Packages

If any of your packages override the Package:boostrap() method then you'll have to make sure that the return type is void.

/**
 * {@inheritdoc}
 */
protected function bootstrap(): void
{

}

Services

The return type of the register method of your custom services must be void.

/**
 * {@inheritdoc}
 */
public function register(): void
{

}

Validator

Custom validation rules that take parameters must no longer implement the WithParametersInterface. Parameters will have to be injected through the constructor.