Re: PHP_Func
| From: | Aidan Lister | Date: | Mon, 26 Apr 2004 15:10:11 +0000 |
| Subject: | Re: PHP_Func | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28378@lists.php.net to get a copy of this message | ||
"Lukas Smith" <smith@backendmedia.com> wrote in message
news:408D1EF0.3060106@backendmedia.com...
> Aidan Lister wrote:
>
> > I was thinking to myself, why doesn't PEAR have a set of functions that
> > everyone, for every project ends up rewriting? Surely that's what we're
> > about here, reusability.
> >
> >
> > include 'function.microtime_str.php'; // tell me you haven't recreated
this
> > function at least 100 times
> >
> > http://ircphp.com/users/imho/?file=function.microtime_str.php
>
> the logic being that somethings will never make it into PHP itself since
> they can be done sufficiently fast in PHP or are considered to be
bloat.
Makes sense.
>
> > Then I was thinking, well, why stop there - why not introduce
> > implementations of functions that are lacking in older versions of php -
god
> > knows the PHP Manual is full of them.
> >
> > For example,
> > http://ircphp.com/users/imho/?file=function.scandir.php
> >
> > http://ircphp.com/users/imho/?file=function.file_get_contents.php
> >
> > http://ircphp.com/users/imho/?file=function.file_put_contents.php
> >
> > Then lsmith said "why not put them in a class", and immediately my brain
> > started ticking.
>
> Err no .. you misunderstood me there.
>
> For the BC functions they obviously shouldnt be in a class.
Ah, ofcourse, my bad.
>
> If we add our own stuff they need to be in a class however to prevent
> namespace issues .. or we could add our own "pearfoobar_" function prefix.
Either is a good solution, but I think it is a good thing to investigate.
>
> > PHP_Func, a class for extending and replacing basic PHP functionality.
All
> > functions would be abstract, and called as such.
> >
> > eg. PHP_Func::file_get_contents();
>
> so this wouldnt make sense .. it would just add bloat.
I'd argue it provided solutions and increased reusability for common,
tedious problems.
> you want to be able to call file_get_contents() normally. its just that
> at the beginning of your code you say "please include all needed code to
> make this as close as possible to php version x.y.z if needed"
>
> > Anyway, that's my idea... I'd love any feedback, whether people think
it's a
> > good idea, etc.
>
> beyond that I think there are several functions I have tried to get into
> internals@ which I need over and over again in my PEAR modules:
>
> like being able to merge multi dimensional arrays
> figure out if a file
> is includeable or not.
http://www.ircphp.com/users/imho/?file=function.file_exists_incpath.php
> actually all of these are bad examples as they
> would be better implemented in C. however some things can be done
> sufficiently fast in php itself but are still often required. actually
> it seems that serialize() can be done quicker in PHP then the current
> implementation provided in C :-)
(http://www.zend.com/zend/week/week179.php)
So is that a Nay?
>
> regards,
> Lukas Smith
> smith@backendmedia.com
> _______________________________
> BackendMedia
> www.backendmedia.com
> berlin@backendmedia.com
>
> Linn Zwoch Smith GbR
> Pariser Str. 44
> D-10707 Berlin
>
> Tel +49 30 83 22 50 00
> Fax +49 30 83 22 50 07