From 05709908a7f529d4e49534b687b0f31884e95132 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 24 Jun 2014 17:49:18 +0200 Subject: [PATCH] Fix composer app issues with cake.php --- app/Console/cake.php | 13 ++++++++++--- lib/Cake/Console/Templates/skel/Console/cake.php | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/Console/cake.php b/app/Console/cake.php index f708a4104..e9afefdb4 100644 --- a/app/Console/cake.php +++ b/app/Console/cake.php @@ -25,11 +25,18 @@ $dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; if (function_exists('ini_set')) { $root = dirname(dirname(dirname(__FILE__))); + $appDir = basename(dirname(dirname(__FILE__))); + $install = $root . DS . 'lib'; + $composerInstall = $root . DS . $appDir . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; - // the following line differs from its sibling + // the following lines differ from its sibling // /lib/Cake/Console/Templates/skel/Console/cake.php - ini_set('include_path', $root . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); - unset($root); + if (file_exists($composerInstall . DS . $dispatcher)) { + $install = $composerInstall; + } + + ini_set('include_path', $install . PATH_SEPARATOR . ini_get('include_path')); + unset($root, $appDir, $install, $composerInstall); } if (!include $dispatcher) { diff --git a/lib/Cake/Console/Templates/skel/Console/cake.php b/lib/Cake/Console/Templates/skel/Console/cake.php index 2950e0c6c..f5b262a2a 100644 --- a/lib/Cake/Console/Templates/skel/Console/cake.php +++ b/lib/Cake/Console/Templates/skel/Console/cake.php @@ -24,11 +24,20 @@ $dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; if (function_exists('ini_set')) { $root = dirname(dirname(dirname(__FILE__))); + $appDir = basename(dirname(dirname(__FILE__))); + $install = $root . DS . 'lib'; + $composerInstall = $root . DS . $appDir . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; - // the following line differs from its sibling + // the following lines differ from its sibling // /app/Console/cake.php - ini_set('include_path', $root . PATH_SEPARATOR . __CAKE_PATH__ . PATH_SEPARATOR . ini_get('include_path')); - unset($root); + if (file_exists($composerInstall . DS . $dispatcher)) { + $install = $composerInstall; + } elseif (!file_exists($install . DS . $dispatcher)) { + $install = $root . PATH_SEPARATOR . __CAKE_PATH__; + } + + ini_set('include_path', $install . PATH_SEPARATOR . ini_get('include_path')); + unset($root, $appDir, $install, $composerInstall); } if (!include $dispatcher) {