myException is not autoloaded

Discussion specific to symfony 1.1.x stable

Moderator: hartym

myException is not autoloaded

Postby nosilume » Wed May 28, 2008 8:55 am

Hi all!
I have a problem with a custom exception class, myException, which is a wrapper for sfException.
<span name="php"><code><span style="color: #000000">
<span style="color: #0000BB"><?php </span><span style="color: #007700">class </span><span style="color: #0000BB">myException </span><span style="color: #007700">extends </span><span style="color: #0000BB">sfException </span><span style="color: #007700">{} </span><span style="color: #0000BB">?></span>
</span>
</code></span>
The file is called "myException.php" and is inside of lib/
If I use <span name="php"><code><span style="color: #000000">
<span style="color: #0000BB"><?php </span><span style="color: #007700">throw new </span><span style="color: #0000BB">myException</span><span style="color: #007700">(</span><span style="color: #DD0000">"foobar"</span><span style="color: #007700">) </span><span style="color: #0000BB">?></span>
</span>
</code></span>
, I get an error Fatal error: Class 'myException' not found…. But if I use
<span name="php"><code><span style="color: #000000">
<span style="color: #0000BB"><?php </span><span style="color: #007700">throw new </span><span style="color: #0000BB">sfException</span><span style="color: #007700">(</span><span style="color: #DD0000">"foobar"</span><span style="color: #007700">) </span><span style="color: #0000BB">?></span>
</span>
</code></span> instead, the code is working. I'm using 1.1-DEV. I hope someone can help me!

Thank you very much,
Christoph
nosilume
Junior Member
 
Posts: 23
Joined: Fri Nov 16, 2007 4:42 pm

Re: myException is not autoloaded

Postby snowkrash » Wed May 28, 2008 9:09 am

Did you clear the Symfony cache before you tried to run?

This is always necessary after changes in config or adding/removing extra classes.
snowkrash
Faithful Member
 
Posts: 518
Joined: Thu Jul 13, 2006 4:48 pm
Location: The Netherlands

Re: myException is not autoloaded

Postby nosilume » Wed May 28, 2008 9:14 am

I cleared it several times, although i thought, this is not neccassery in 1.1.
nosilume
Junior Member
 
Posts: 23
Joined: Fri Nov 16, 2007 4:42 pm

Re: myException is not autoloaded

Postby snowkrash » Thu May 29, 2008 8:34 am

In which lib/ directories are the two files: the one with the myException class and the one that calls it?
snowkrash
Faithful Member
 
Posts: 518
Joined: Thu Jul 13, 2006 4:48 pm
Location: The Netherlands

Re: myException is not autoloaded

Postby nosilume » Thu May 29, 2008 2:56 pm

myException.php is in $project/lib and the exception is thrown in an action file.
nosilume
Junior Member
 
Posts: 23
Joined: Fri Nov 16, 2007 4:42 pm

Re: myException is not autoloaded

Postby snowkrash » Fri May 30, 2008 8:32 am

If I am correct, class files should be named xxxx.class.php. Does renaming help?
snowkrash
Faithful Member
 
Posts: 518
Joined: Thu Jul 13, 2006 4:48 pm
Location: The Netherlands


Return to symfony 1.1

Who is online

Users browsing this forum: No registered users and 1 guest