Errors trying build an application using CakePHP 5.x

Just remove the version constraint:

# as of today it gives you 5.1.2
composer create-project --prefer-dist cakephp/app  cms

And if you really want to put a version constraint in

composer create-project --prefer-dist cakephp/app=^5.1.2  cms

And if you want to upgrade to the latest cakephp (5.2.5)

cd cms
composer require cakephp/cakephp:^5.2