ZF2, Doctrine 2, and Composer autoload class redeclared error.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ZF2, Doctrine 2, and Composer autoload class redeclared error.

John Wynstra
I am experimenting with Doctrine 2 in ZendFramework 2 and am getting the
following error:

PHP Fatal error:  Cannot redeclare class Application\\Entity\\articles in
../../ZendSkeletonApplication/module/Application/src/Application/Entity/articles.php
on line 8

This is a simple Entity class and I know that I don't have a duplicate
class in the project.

I have looked some posts about this, and I am wondering about some type of
autoloading routine that is not aware that the class is already declared.
 Any idea as to how to trouble shoot this would be appreciated.

Feel like this should be simple or obvious, but alas, it is not for me.  My
experimentation is following the zend tutorial from Feb 2013.  Tutorial
worked fine.  When I started experimenting with my own database, I got the
class re-declaration problem.


--
------------------------------------------------
John Wynstra
Library Information Systems Specialist
Rod Library
University of Northern Iowa
Cedar Falls, IA  50613
[hidden email]
(319)273-6399
------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: ZF2, Doctrine 2, and Composer autoload class redeclared error.

Marco Pivetta
On 7 March 2014 21:10, John Wynstra <[hidden email]> wrote:

> I am experimenting with Doctrine 2 in ZendFramework 2 and am getting the
> following error:
>
> PHP Fatal error:  Cannot redeclare class Application\\Entity\\articles in
>
> ../../ZendSkeletonApplication/module/Application/src/Application/Entity/articles.php
> on line 8
>

This looks like a typo of some kind. The information provided is
insufficient to debug the problem, though.

Could you provide a gist with the file paths, autoloader config and file
contents of the class?


Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/
Reply | Threaded
Open this post in threaded view
|

Re: ZF2, Doctrine 2, and Composer autoload class redeclared error.

Norbert Máté
Does this happen when you try to run composer install?
Sometime it happens to me also. I have to disable apc cache (cli) to be
able to run composer install.

Regards,
Norbert.
Reply | Threaded
Open this post in threaded view
|

Re: ZF2, Doctrine 2, and Composer autoload class redeclared error.

John Wynstra
In reply to this post by Marco Pivetta
Meant to send this to the list, but had only sent it to Marco.

================================================

OK.  I HAD declared the class twice, and it was not apparent until I logged
onto the Linux server via putty to examine the directory.   My  Entites
directory contained the following two files both declaring the same class:

articles.php
Articles.php

ONLY ONE of them was present in my Zend Studio project. I had renamed the
file in Zend Studio, but it did not delete the other file on the server.
 After discovering this, I even tried a download from server and the extra
file did not come down.

 Thanks for offering to help.  It was actually your request for a gist with
file paths that caused me to discover this.   I have no idea why I decided
to log on to the server directly because I already had the project open in
Zend Studio.


On Tue, Mar 11, 2014 at 8:00 PM, Marco Pivetta <[hidden email]> wrote:

>
>
> On 7 March 2014 21:10, John Wynstra <[hidden email]> wrote:
>
>> I am experimenting with Doctrine 2 in ZendFramework 2 and am getting the
>> following error:
>>
>> PHP Fatal error:  Cannot redeclare class Application\\Entity\\articles in
>>
>> ../../ZendSkeletonApplication/module/Application/src/Application/Entity/articles.php
>> on line 8
>>
>
> This looks like a typo of some kind. The information provided is
> insufficient to debug the problem, though.
>
> Could you provide a gist with the file paths, autoloader config and file
> contents of the class?
>
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
>


--
------------------------------------------------
John Wynstra
Library Information Systems Specialist
Rod Library
University of Northern Iowa
Cedar Falls, IA  50613
[hidden email]
(319)273-6399
------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: ZF2, Doctrine 2, and Composer autoload class redeclared error.

David Muir-2
Oh the joys of case-insensitive filesystems… I'm looking at you NTFS and HFS+…

In your case, even after you downloaded the files from the server, you would only end up with one articles.php file since one would have overwritten the other.

I had a similar issue with a copy of my project from my MBP to my Ubuntu desktop. Certain composer libraries were refusing to auto-load. I tried running composer update and composer dump-autoload, and still no luck. I then did a manual require_once for the class I was trying to load, when I hit the same issue as you. Fixed it by wiping my vendor folder, and running composer install. Things get even more fun with VCS's that don't track case renames properly...

Glad you got it all sorted.

Cheers,
David




On 13/03/2014, at 7:19 AM, John Wynstra <[hidden email]> wrote:

> Meant to send this to the list, but had only sent it to Marco.
>
> ================================================
>
> OK.  I HAD declared the class twice, and it was not apparent until I logged
> onto the Linux server via putty to examine the directory.   My  Entites
> directory contained the following two files both declaring the same class:
>
> articles.php
> Articles.php
>
> ONLY ONE of them was present in my Zend Studio project. I had renamed the
> file in Zend Studio, but it did not delete the other file on the server.
> After discovering this, I even tried a download from server and the extra
> file did not come down.
>
> Thanks for offering to help.  It was actually your request for a gist with
> file paths that caused me to discover this.   I have no idea why I decided
> to log on to the server directly because I already had the project open in
> Zend Studio.
>
>
> On Tue, Mar 11, 2014 at 8:00 PM, Marco Pivetta <[hidden email]> wrote:
>
>>
>>
>> On 7 March 2014 21:10, John Wynstra <[hidden email]> wrote:
>>
>>> I am experimenting with Doctrine 2 in ZendFramework 2 and am getting the
>>> following error:
>>>
>>> PHP Fatal error:  Cannot redeclare class Application\\Entity\\articles in
>>>
>>> ../../ZendSkeletonApplication/module/Application/src/Application/Entity/articles.php
>>> on line 8
>>>
>>
>> This looks like a typo of some kind. The information provided is
>> insufficient to debug the problem, though.
>>
>> Could you provide a gist with the file paths, autoloader config and file
>> contents of the class?
>>
>>
>> Marco Pivetta
>>
>> http://twitter.com/Ocramius
>>
>> http://ocramius.github.com/
>>
>>
>
>
> --
> ------------------------------------------------
> John Wynstra
> Library Information Systems Specialist
> Rod Library
> University of Northern Iowa
> Cedar Falls, IA  50613
> [hidden email]
> (319)273-6399
> ------------------------------------------------


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]