problem including files with relative paths

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
m2mtech
Forum Newbie
Posts: 3
Joined: Wed Aug 15, 2007 3:15 am

problem including files with relative paths

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
m2mtech
Forum Newbie
Posts: 3
Joined: Wed Aug 15, 2007 3:15 am

Post 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.
Post Reply