Page 1 of 1

problem including files with relative paths

Posted: Wed Aug 15, 2007 3:39 am
by m2mtech
Some php versions seem to have a problem with relative paths when using include_once or require once:
Fatal error: Cannot redeclare class swift_classloader in ./3party/swift/Swift-3.3.0-php4/lib/Swift/Log/../ClassLoader.php on line 19
It happens with php4 and php5 - however I noticed this error only on Macs.
In this particular case I used:
  • Swift: Swift-3.3.0-php4
    PHP: 4.4.7
    OS: Mac OS X 10.3.9
The problem is, that
  • lib/Swift/Log/../ClassLoader.php
    lib/Swift/ClassLoader.php
are the same files, but my php does not recognize that.
A work around is to change all

Code: Select all

require_once dirname(__FILE__) . "/../ClassLoader.php";
to

Code: Select all

require_once SWIFT_ABS_PATH . "/ClassLoader.php";
Nevertheless, SWIFT is a wonderful tool, keep on working!
Thanks for your attention ;)
Martin

Posted: Wed Aug 15, 2007 12:24 pm
by Chris Corbyn
Odd. I can fix that pretty easily (I hope) with a call to realpath(). It should just work though logically.

Thanks for the heads-up.

PS: I run a mac and have never had this problem, nor has anyone else mentioned it. I'm curious what Mac OS version you've witnessed this on? :) I also use 4.4.7 (among others) when testing my code for PHP 4.

Posted: Wed Aug 15, 2007 1:20 pm
by m2mtech
It's OS X 10.3.9 ...
... when I saw this problem the first time (not Swiftmailer) ... google said it's a Mac problem :(

Actually changing all calls to ClassLoader.php to

Code: Select all

require_once SWIFT_ABS_PATH . "/Swift/ClassLoader.php";
works quite fine.