Wednesday, July 9, 2014

paths in cake environment being mangled

Hi all,

Can anyone explain this behaviour?

This setup worked for me prior to upgrading my pc from XP to Win7. I am now assuming that I have rebuilt my folder structure differently from the original setup with some detail missing/changed that has become invisible to me. However, the mangling of the path is the mystery part for me.

In brief (more details below), when i name the cake folder as follows the cake environment returns the following:
c:\www\apps\serv\cake\235    is mangled to ->    c:\www\apps\serv\cake5
c:\www\apps\serv\cake\2.3.5    is mangled to ->    c:\www\apps\serv\cake.3.5
c:\www\apps\serv\cake\v235    is unchanged  ->    c:\www\apps\serv\cake\v235.

Many thanx, DaveT.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's my environment:
Server Software     Apache/2.4.7 (Win32)
    (with rewrite module enabled and correctly displayed by phpinfo)
Document Root     c:/www/pub
Php Version     5.5.10
CAKE_VERSION     2.3.5
Path     c:\WINDOWS\system32;c:\WINDOWS\System32\Wbem;c:\WINDOWS\System32\WindowsPowerShell\v1.0\;c:\WINDOWS;c:\www\apps\serv\php;c:\www\apps\serv\mysql\bin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's my file/folder structure:
c:\www
+---apps
|   \---serv
|       +---apache
|       +---cake
|       |   +---134
    . . .
|       |   +---235
|       |   +---245
|       |   \---_apps
|       |       +---GPD
|       |       +---GPDdev
|       |       +---promats
|       |       +---promatsdev
|       |       \---_Templates
|       |           +---134_default
|       |           +---134_skel
    . . .
|       |           +---234_skel
|       |           \---234_skel_dave
|       +---mysql
|       +---php
|       \---pma
+---priv
|   +---data
|   |   +---gpd
|   |   +---gpddev
|   |   +---promats
|   |   +---promatsdev
|   |   \---_config
|   \---share
+---pub
|   +---GPD            (same structure as c:\www\pub\promats)
|   +---GPDdev        (same structure as c:\www\pub\promats)
|   +---promats
|   |   +---css
|   |   +---files
|   |   +---img
|   |   \---js
|   |       \---jquery
|   +---promatsdev    (same structure as c:\www\pub\promats)
|   \---_files
\---tmp

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's my c:\www\pub\promats\index.php:
Only variables I've ever changed here are 'ROOT', 'APP_DIR', and 'CAKE_CORE_INCLUDE_PATH'.

<?php
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}

if (!defined('ROOT')) {
//    as defined by me
    define('ROOT', dirname(dirname(dirname(__FILE__))) . DS . 'apps'. DS . 'serv'. DS . 'cake'. DS . '_apps');
    echo ('</br> ROOT is: ' . dirname(dirname(dirname(__FILE__))) . DS . 'apps'. DS . 'serv'. DS . 'cake'. DS . '_apps');
//    as defined by cake for original setup
//    define('ROOT', dirname(dirname(dirname(__FILE__))));
}

if (!defined('APP_DIR')) {
//    as defined by me
    define('APP_DIR', basename(dirname(__FILE__)));
    echo ('</br> APP_DIR is: ' . basename(dirname(__FILE__)));
//    as defined by cake for original setup
//    define('APP_DIR', basename(dirname(dirname(__FILE__))));
}

//as defined by me
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))) . DS . 'apps' . DS . 'serv' . DS . 'cake' . DS . '235' . DS . 'lib');
echo ('</br> CAKE_CORE_INCLUDE_PATH is: ' . dirname(dirname(dirname(__FILE__))) . DS . 'apps' . DS . 'serv' . DS . 'cake' . DS . '235' . DS . 'lib');

if (!defined('WEBROOT_DIR')) {
    define('WEBROOT_DIR', basename(dirname(__FILE__)));
    echo ('</br> WEBROOT_DIR is: ' . basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
    define('WWW_ROOT', dirname(__FILE__) . DS);
    echo ('</br> WWW_ROOT is: ' . dirname(__FILE__));
}

// for built-in server
if (php_sapi_name() === 'cli-server') {
    if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) {
        return false;
    }
    $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    if (function_exists('ini_set')) {
        ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
    }
    if (!include ('Cake' . DS . 'bootstrap.php')) {
        $failed = true;
    }
} else {
    if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
        $failed = true;
    }
}

// DJT: 3 lines for debugging routing
echo ('</br> include_path is: ' . ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
echo ('</br> CAKE_CORE_INCLUDE_PATH is: ' . CAKE_CORE_INCLUDE_PATH);
echo ('</br> _');

if (!empty($failed)) {
    trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}

App::uses('Dispatcher', 'Routing');

$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(
    new CakeRequest(),
    new CakeResponse()
);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Output from echo statements in c:\www\pub\promats\index.php:
(when cake folder is: 'c:\www\apps\serv\cake\235')
ROOT is:    c:\www\apps\serv\cake\_apps
APP_DIR is:    promats
    CAKE_CORE_INCLUDE_PATH is:    c:\www\apps\serv\cake\235\lib

    (if i rename the cake folder to 'c:\www\apps\serv\cake\2.3.5' this changes to:)
    CAKE_CORE_INCLUDE_PATH is:    c:\www\apps\serv\cake\2.3.5\lib

    (if i rename the cake folder to 'c:\www\apps\serv\cake\v235' this changes to:)
    CAKE_CORE_INCLUDE_PATH is:    c:\www\apps\serv\cake\v235\lib
WEBROOT_DIR is:    promats
WWW_ROOT is:    c:\www\pub\promats
include_path is:    c:\www\apps\serv\cake\_apps\lib;.;c:\php\pear
    CAKE_CORE_INCLUDE_PATH is:    c:\www\apps\serv\cake\235\lib

    (if i rename the cake folder to 'c:\www\apps\serv\cake\2.3.5' this changes to:)
    CAKE_CORE_INCLUDE_PATH is:    c:\www\apps\serv\cake\2.3.5\lib

    (if i rename the cake folder to 'c:\www\apps\serv\cake\v235' this changes to:)
    CAKE_CORE_INCLUDE_PATH is:    c:\www\apps\serv\cake\v235\lib

// ==== all as expected ===

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CakePHP Environment:
(when cake folder is: 'c:\www\apps\serv\cake\235')
Environment Variable     Value
APP     c:\www\apps\serv\cake\_apps\promats\
APP_DIR     promats
APPLIBS     c:\www\apps\serv\cake\_apps\promats\Lib\
CACHE     c:\www\apps\serv\cake\_apps\promats\tmp\cache\
CAKE_VERSION     2.3.5
    CAKE     c:\www\apps\serv\cake5\lib\Cake\
    CAKE_CORE_INCLUDE_PATH     c:\www\apps\serv\cake5\lib
    CORE_PATH     c:\www\apps\serv\cake5\lib\

    (if i rename the cake folder to 'c:\www\apps\serv\cake\2.3.5' this changes to:)
    CAKE     c:\www\apps\serv\cake.3.5\lib\Cake\
    CAKE_CORE_INCLUDE_PATH     c:\www\apps\serv\cake.3.5\lib
    CORE_PATH     c:\www\apps\serv\cake.3.5\lib\

    (if i rename the cake folder to 'c:\www\apps\serv\cake\v235' this changes to:)
    CAKE     c:\www\apps\serv\cake\v235\lib\Cake\
    CAKE_CORE_INCLUDE_PATH     c:\www\apps\serv\cake\v235\lib
    CORE_PATH     c:\www\apps\serv\cake\v235\lib\

// ==== first two messed up, last as expected ===

CSS     c:\www\pub\promats\css\
IMAGES     c:\www\pub\promats\img\
JS     c:\www\pub\promats\js\
LOGS     c:\www\apps\serv\cake\_apps\promats\tmp\logs\
ROOT     c:\www\apps\serv\cake\_apps
TESTS     c:\www\apps\serv\cake\_apps\promats\Test\
TMP     c:\www\apps\serv\cake\_apps\promats\tmp\
VENDORS     c:\www\apps\serv\cake\_apps\vendors\
WEBROOT_DIR     promats
WWW_ROOT     c:\www\pub\promats\

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: