Removing Require_once

8 messages Options
Embed this post
Permalink
#2Will

Removing Require_once

Reply Threaded More More options
Print post
Permalink
The instructions given here:

http://framework.zend.com/manual/en/performance.classloading.html#performance.classloading.striprequires.sed

Don't work in terminal on OSX.   Does anyone have an alternative ?

Is it possible to make a production ready version of the framework available? one with the require_once statements removed. I know there is a bit of a discussion on here about it not mattering quite so much with php5.2+, but even so, it's one of the 1st instructions in the performance  chapter.


weierophinney

Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
-- aSecondWill <[hidden email]> wrote
(on Monday, 29 June 2009, 06:09 PM -0700):

> The instructions given here:
>
> http://framework.zend.com/manual/en/performance.classloading.html#performance.classloading.striprequires.sed
>
> Don't work in terminal on OSX.   Does anyone have an alternative ?
>
> Is it possible to make a production ready version of the framework
> available? one with the require_once statements removed. I know there is a
> bit of a discussion on here about it not mattering quite so much with
> php5.2+, but even so, it's one of the 1st instructions in the performance
> chapter.

Just a clarification: those recommendations were made based on testing
with PHP 5.2 series versions. Even with the realpath cache in PHP 5.2,
you get better performance after stripping require_once calls. However,
the most benefit comes from stripping them *and* using an opcode cache.
Without the opcode cache, the benefits, while measurable, are still
negligible.

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
Matthew Ratzloff

Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
In reply to this post by #2Will
The documentation assumes GNU versions of find and sed, and should probably note that.  The equivalent BSD command (which will of course work on Mac OS X) is:

% cd path/to/ZendFramework/library
% find . -name '*.php' | grep -v './Loader/Autoloader.php' | \
xargs sed -E -i~ 's/(require_once)/\/\/ \1/g'

I've tested this and it works.  It might be good to add this to the documentation.

-Matt

On Mon, Jun 29, 2009 at 6:09 PM, aSecondWill <[hidden email]> wrote:

The instructions given here:

http://framework.zend.com/manual/en/performance.classloading.html#performance.classloading.striprequires.sed

Don't work in terminal on OSX.   Does anyone have an alternative ?

Is it possible to make a production ready version of the framework
available? one with the require_once statements removed. I know there is a
bit of a discussion on here about it not mattering quite so much with
php5.2+, but even so, it's one of the 1st instructions in the performance
chapter.



--
View this message in context: http://www.nabble.com/Removing-Require_once-tp24261910p24261910.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Matthew Ratzloff

Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
You'll need to delete all the backup versions of the files afterward with this command, BTW.  I don't think BSD sed will permit in-place editing using stdin.

The complete command is therefore:

% cd path/to/ZendFramework/library
% find . -name '*.php' | grep -v './Loader/Autoloader.php' | \
xargs sed -E -i~ 's/(require_once)/\/\/ \1/g'
% find . -name '*.php~' | xargs rm -f

-Matt

On Mon, Jun 29, 2009 at 7:03 PM, Matthew Ratzloff <[hidden email]> wrote:
The documentation assumes GNU versions of find and sed, and should probably note that.  The equivalent BSD command (which will of course work on Mac OS X) is:

% cd path/to/ZendFramework/library
% find . -name '*.php' | grep -v './Loader/Autoloader.php' | \
xargs sed -E -i~ 's/(require_once)/\/\/ \1/g'

I've tested this and it works.  It might be good to add this to the documentation.

-Matt

On Mon, Jun 29, 2009 at 6:09 PM, aSecondWill <[hidden email]> wrote:

The instructions given here:

http://framework.zend.com/manual/en/performance.classloading.html#performance.classloading.striprequires.sed

Don't work in terminal on OSX.   Does anyone have an alternative ?

Is it possible to make a production ready version of the framework
available? one with the require_once statements removed. I know there is a
bit of a discussion on here about it not mattering quite so much with
php5.2+, but even so, it's one of the 1st instructions in the performance
chapter.



--
View this message in context: http://www.nabble.com/Removing-Require_once-tp24261910p24261910.html
Sent from the Zend Framework mailing list archive at Nabble.com.



#2Will

Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
Thanks! I got that working after a bit of fiddling with spaces etc. It made almost no difference to the page load time, even when applied to my extra application libraries, Doctrine etc. - its taking 600ms to proccess everything.(roughly, varies quite a bit - 1st load of a page a bit slower, posibly due to doctrine query caching kicking in on subsequant loads - who knows?)



Bugzilla from dado@krizevci.info

Re: Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
On Tuesday 30 June 2009 05:53:27 aSecondWill wrote:

> Thanks! I got that working after a bit of fiddling with spaces etc. It made
> almost no difference to the page load time, even when applied to my extra
> application libraries, Doctrine etc. - its taking 600ms to proccess
> everything.(roughly, varies quite a bit - 1st load of a page a bit slower,
> posibly due to doctrine query caching kicking in on subsequant loads - who
> knows?)

XDebug should know.

--
Dado
takeshin

Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
In reply to this post by Matthew Ratzloff

Matthew Ratzloff wrote:
The complete command is therefore:

% cd path/to/ZendFramework/library
% find . -name '*.php' | grep -v './Loader/Autoloader.php' | \
xargs sed -E -i~ 's/(require_once)/\/\/ \1/g'
% find . -name '*.php~' | xargs rm -f
Shouldn't this script be part of the ZF package?

--
regards
takeshin
keith Pope-4

Re: Re: Re[fw-general] moving Require_once

Reply Threaded More More options
Print post
Permalink
Heres one for Apache Ant

<target name="deploy">
        <echo message="---- Removing require_once ----" />
        <replaceregexp byline="true">
            <regexp pattern="require_once 'Zend/"/>
            <substitution expression="// require_once 'Zend/"/>
            <fileset dir="${basedir}/library/Zend"
excludes="**/*Autoloader.php" includes="**/*.php" />
        </replaceregexp>
    </target>

2009/7/5 admirau <[hidden email]>:

>
>
>
> Matthew Ratzloff wrote:
>>
>> The complete command is therefore:
>>
>> % cd path/to/ZendFramework/library
>> % find . -name '*.php' | grep -v './Loader/Autoloader.php' | \
>> xargs sed -E -i~ 's/(require_once)/\/\/ \1/g'
>> % find . -name '*.php~' | xargs rm -f
>>
>
> Shouldn't this script be part of the ZF package?
>
> --
> regards
> takeshin
>
> --
> View this message in context: http://www.nabble.com/Removing-Require_once-tp24261910p24341443.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>



--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------