You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by Ivan Habunek <iv...@gmail.com> on 2012/01/02 14:51:37 UTC

Autoloader class

There's one thing that's been bugging me for ages, and that's the
array used for autoloading which is located at the beginning of
Logger.php ($_classes).

I think it should be moved into a separate class, e.g.
LoggerAutoLoader.php, along with the autoload() method. It's huge, and
it is not logically connected to the Logger class functionality.
Always having to scroll the 150 or so lines is really annoying.

Does anybody have any objection to this?

Regards,
Ivan

Re: Autoloader class

Posted by Christian Grobmeier <gr...@gmail.com>.
On Tue, Jan 3, 2012 at 8:44 AM, Ivan Habunek <iv...@gmail.com> wrote:
> On 2 January 2012 17:45, Christian Grobmeier <gr...@gmail.com> wrote:
>> +1
>> Sad but true.
>>
>> I just had a random thought. Not sure if it is true because I am not
>> that hardcore user of git...
>> but wouldn't it be very easy to maintain two branches of log4php, at
>> least for a while? One with namespace one without
>
> If we wanted, we could do this. One option is to stop development on
> the 5.2. branch and just develop the 5.3 branch. But that seems unfair
> because a majority of people still use 5.2 and they wouldn't get all
> the cool new stuff. :-) I would not like to develop features on both
> branches simultaneously. That's just too much work IMHO. My proposal
> is to wait another half-year or so and see what happens.

I agree, 5.2 is to widely spread (I couldn't use log4php myself if it
would come with namespacing), but I thought the git wonder is
something like: develop in branch a, push it to branch b, go. If this
is not the case, then lets wait. Otherwise there is the git experiment
running at the ASF.

> I have moved the autoloader to LoggerAutoloader class in trunk. Looks
> a bit nicer now.

Thanks man

>
> Regards,
> Ivan



-- 
http://www.grobmeier.de
https://www.timeandbill.de

Re: Autoloader class

Posted by Florian Semm <fl...@gmx.de>.
Am 03.01.2012 08:44, schrieb Ivan Habunek:
> On 2 January 2012 17:45, Christian Grobmeier<gr...@gmail.com>  wrote:
>> +1
>> Sad but true.
>>
>> I just had a random thought. Not sure if it is true because I am not
>> that hardcore user of git...
>> but wouldn't it be very easy to maintain two branches of log4php, at
>> least for a while? One with namespace one without
> If we wanted, we could do this. One option is to stop development on
> the 5.2. branch and just develop the 5.3 branch. But that seems unfair
> because a majority of people still use 5.2 and they wouldn't get all
> the cool new stuff. :-) I would not like to develop features on both
> branches simultaneously. That's just too much work IMHO. My proposal
> is to wait another half-year or so and see what happens.

Thats true. Namespaces would be cool, but if we use two 
developing-branches the "maintaining-cost" are too high.

> I have moved the autoloader to LoggerAutoloader class in trunk. Looks
> a bit nicer now.
Nice.

> Regards,
> Ivan


Re: Autoloader class

Posted by Ivan Habunek <iv...@gmail.com>.
On 2 January 2012 17:45, Christian Grobmeier <gr...@gmail.com> wrote:
> +1
> Sad but true.
>
> I just had a random thought. Not sure if it is true because I am not
> that hardcore user of git...
> but wouldn't it be very easy to maintain two branches of log4php, at
> least for a while? One with namespace one without

If we wanted, we could do this. One option is to stop development on
the 5.2. branch and just develop the 5.3 branch. But that seems unfair
because a majority of people still use 5.2 and they wouldn't get all
the cool new stuff. :-) I would not like to develop features on both
branches simultaneously. That's just too much work IMHO. My proposal
is to wait another half-year or so and see what happens.

I have moved the autoloader to LoggerAutoloader class in trunk. Looks
a bit nicer now.

Regards,
Ivan

Re: Autoloader class

Posted by Christian Grobmeier <gr...@gmail.com>.
On Mon, Jan 2, 2012 at 4:18 PM, Ivan Habunek <iv...@gmail.com> wrote:
> Hi Florian,
>
> On 2 January 2012 16:07, Florian Semm <fl...@gmx.de> wrote:
>> That's a good point and it isn't much work.
>>
>> Do we need the $_classes array or is a naming-conversion for the classes
>> (PEAR/Zend) an alternative solution?
>
> I'm not a fan of the PEAR naming convention (and neither is Christian).
>
> Anyway, we would rather not change the naming convention at this point
> in time. It's a lot of work and does not contribute much to the code
> base. The long-term plan is to start using namespaces at some time in
> the future. At that point we will re-think the whole naming
> convention.
>
> The problem is that namespaces would make log4php incompatible with
> PHP < 5.3 so this is currently not acceptable because a majority of
> people is still using 5.2 (I blame the hosting firms).

+1
Sad but true.

I just had a random thought. Not sure if it is true because I am not
that hardcore user of git...
but wouldn't it be very easy to maintain two branches of log4php, at
least for a while? One with namespace one without

Cheers


>
> By using namespaces we could rename LoggerLayoutPattern to
> \apache\log4php\layouts\PatternLayout, or something similar. This
> would make everything nicer, and we can write a generic autoload
> method instead of having the classes array.
>
>> btw: happy new year ;)
>
> To you too! :-)
>
> Ivan



-- 
http://www.grobmeier.de
https://www.timeandbill.de

Re: Autoloader class

Posted by Ivan Habunek <iv...@gmail.com>.
On 2 January 2012 16:32, Florian Semm <fl...@gmx.de> wrote:
> PEAR naming conversion was just a example for pseudo namespaces and it is
> backward compatible.

I understand, I just think it's not worth the effort.

> Namespaces are not planed for the 2.3 release, right?

Short answer: no.

Long answer: Can't speak for everybody but I think it would not be a
good idea until 5.3 is more widely used. We could in theory make a
branch, but I'm not keen on supporting two parallel branches. :-)

> Don't forget PHP4! ;)

LOL, yeah. :D

>> By using namespaces we could rename LoggerLayoutPattern to
>> \apache\log4php\layouts\PatternLayout, or something similar. This
>> would make everything nicer, and we can write a generic autoload
>> method instead of having the classes array.
>
> the autoloader method is in this case very easy:
>
> $class = str_replace('\\', '/', $class) . '.php';
> require_once($class);

Yeah, I have a similar setup on some larger projects at work. It's
neat and simple.

Regards,
Ivan

Re: Autoloader class

Posted by Florian Semm <fl...@gmx.de>.
Am 02.01.2012 16:18, schrieb Ivan Habunek:
> Hi Florian,
>
> On 2 January 2012 16:07, Florian Semm<fl...@gmx.de>  wrote:
>> That's a good point and it isn't much work.
>>
>> Do we need the $_classes array or is a naming-conversion for the classes
>> (PEAR/Zend) an alternative solution?
> I'm not a fan of the PEAR naming convention (and neither is Christian).
>
> Anyway, we would rather not change the naming convention at this point
> in time. It's a lot of work and does not contribute much to the code
> base. The long-term plan is to start using namespaces at some time in
> the future. At that point we will re-think the whole naming
> convention.

PEAR naming conversion was just a example for pseudo namespaces and it 
is backward compatible.

Namespaces are not planed for the 2.3 release, right?

> The problem is that namespaces would make log4php incompatible with
> PHP<  5.3 so this is currently not acceptable because a majority of
> people is still using 5.2 (I blame the hosting firms).

Don't forget PHP4! ;)

> By using namespaces we could rename LoggerLayoutPattern to
> \apache\log4php\layouts\PatternLayout, or something similar. This
> would make everything nicer, and we can write a generic autoload
> method instead of having the classes array.

the autoloader method is in this case very easy:

$class = str_replace('\\', '/', $class) . '.php';
require_once($class);


>> btw: happy new year ;)
> To you too! :-)
>
> Ivan


Re: Autoloader class

Posted by Ivan Habunek <iv...@gmail.com>.
Hi Florian,

On 2 January 2012 16:07, Florian Semm <fl...@gmx.de> wrote:
> That's a good point and it isn't much work.
>
> Do we need the $_classes array or is a naming-conversion for the classes
> (PEAR/Zend) an alternative solution?

I'm not a fan of the PEAR naming convention (and neither is Christian).

Anyway, we would rather not change the naming convention at this point
in time. It's a lot of work and does not contribute much to the code
base. The long-term plan is to start using namespaces at some time in
the future. At that point we will re-think the whole naming
convention.

The problem is that namespaces would make log4php incompatible with
PHP < 5.3 so this is currently not acceptable because a majority of
people is still using 5.2 (I blame the hosting firms).

By using namespaces we could rename LoggerLayoutPattern to
\apache\log4php\layouts\PatternLayout, or something similar. This
would make everything nicer, and we can write a generic autoload
method instead of having the classes array.

> btw: happy new year ;)

To you too! :-)

Ivan

Re: Autoloader class

Posted by Florian Semm <fl...@gmx.de>.
Am 02.01.2012 14:51, schrieb Ivan Habunek:
> There's one thing that's been bugging me for ages, and that's the
> array used for autoloading which is located at the beginning of
> Logger.php ($_classes).
>
> I think it should be moved into a separate class, e.g.
> LoggerAutoLoader.php, along with the autoload() method. It's huge, and
> it is not logically connected to the Logger class functionality.
> Always having to scroll the 150 or so lines is really annoying.

That's a good point and it isn't much work.

Do we need the $_classes array or is a naming-conversion for the classes 
(PEAR/Zend) an alternative solution?

> Does anybody have any objection to this?
>
> Regards,
> Ivan

Regards,

Florian

btw: happy new year ;)

Re: Autoloader class

Posted by Christian Grobmeier <gr...@gmail.com>.
On Mon, Jan 2, 2012 at 2:51 PM, Ivan Habunek <iv...@gmail.com> wrote:
> There's one thing that's been bugging me for ages, and that's the
> array used for autoloading which is located at the beginning of
> Logger.php ($_classes).
>
> I think it should be moved into a separate class, e.g.
> LoggerAutoLoader.php, along with the autoload() method. It's huge, and
> it is not logically connected to the Logger class functionality.
> Always having to scroll the 150 or so lines is really annoying.
>
> Does anybody have any objection to this?

+1

this ugly piece of code really hunted me myself for a while, not sure
why I didn't move it out

Cheers

> Regards,
> Ivan



-- 
http://www.grobmeier.de
https://www.timeandbill.de