Fix composer app issues with cake.php

Refs https://github.com/cakephp/cakephp/pull/3726

This fixes the problem that one has to manually adjust the cake.php Console file after baking a new project - and using composer.
This auto-detects composer and uses the old root one as fallback.

I had to leave the app one as it is and only modify the template one as tests otherwise fail.
Nevermind, I just read the rest of the file.