Re: [fw-general] Zend_Application Bootstrapping

2009-04-26 Thread Matthew Weier O'Phinney
-- gerardroche  wrote
(on Saturday, 25 April 2009, 03:15 PM -0700):
> In the performance guide it says
> 
> "Define your Zend Framework include_path as early as possible
> 
> Continuing from the previous suggestion, another obvious optimization is to
> define your Zend Framework include_path as early as possible in your
> include_path. In most cases, it should be the first path in the list. This
> ensures that files included from Zend Framework are found on the first
> scan."
> 
> If ZF library is set prior to execution and we then set application level
> include paths the include_path will read:
> 
> 1. application level set include_path (application/library)
> 2. include_path set prior to execution (ZF)
> 
> Shouldn't this be the other way round?
> Is this a trivial performance cost?
> 
> If this is not a trivial performance cost would it good to have an
> option in Zend_Application to append application level include paths
> rather than prepend them when setting the include path?

I'm actually being consistent in the above. :)

In most cases, your application level libraries should be scanned before
ZF libraries. You'll note I said "as early as possible" -- which would
be immediately following your application-level include_paths.


> Zend_Application lines 227-232
> 
> public function setIncludePaths(array $paths)
> {
> $path = implode(PATH_SEPARATOR, $paths);
> set_include_path($path . PATH_SEPARATOR . get_include_path());
> return $this;
> }
> 
> to something like:
> 
> public function setIncludePaths(array $paths)
> {
> $path = implode(PATH_SEPARATOR, $paths);
> 
> if ($this->getOption('appendIncludePaths')) {
> $includePath = $path . PATH_SEPARATOR . get_include_path();
> } else {
> $includePath = get_include_path() . PATH_SEPARATOR . $path;
> }
> 
> set_include_path($includePath);
> 
> return $this;
> }
> 
> we could the set it in our config file.
> 
> 
> e.g. ini would read:
> 
> includePaths.library = APPLICATION_PATH "/../library"
> appendIncludePaths = true
> 
> 
> 
> 
> Matthew Weier O'Phinney-3 wrote:
> > 
> > -- Rob Allen  wrote
> > (on Friday, 24 April 2009, 06:23 AM +0100):
> >> On 23 Apr 2009, at 23:42, Matthew Weier O'Phinney wrote:
> >> > That said, we're seeing some momentum by shared hosts as well as
> >> > xAMP stacks to include ZF in the default include_path (Zend Server
> >> > falls in this category as well). In such cases, you may be able to
> >> > bootstrap  your ZF application and still use your preferred version
> >> > of ZF by adding  your include_path.
> >> >
> >> > One sitation we considered was having Zend_Application add a minimal
> >> > include_path to ensure that your ZF include_path includes the path in
> >> > which it is found, if that makes sense. Basically, in the constructor,
> >> > we'd do something like this:
> >> >
> >> >$localPath = realpath(dirname(__FILE__) . '/../');
> >> >set_include_path($localPath . PATH_SEPARATOR . get_include_path());
> >> >
> >> > The problem with this is that it's horribly inefficient if you
> >> > already have ZF on your include_path, and adds overhead on every
> >> > call. We  opted to drop it in order to keep bootstrapping as
> >> > performant as possible.
> >>
> >> Does this imply that you (the ZF team) believe that best practice ZF  
> >> sites do not need the library/ directory on their include_path now?
> > 
> > Not at all. The implications are:
> > 
> >   * It's better to set your include_path at the vhost (preferred) or
> > htaccess (second best) level. For performance reasons, these are the
> > better locations.
> >   
> >   * Having a library/ directory is going to be useful whenever you have
> > custom libraries or other 3rd party libraries (including ZF) that
> > your application will use.
> > 
> > The primary implication is quite simply that the include_path should be
> > set prior to execution whenever possible.
> > 
> > -- 
> > Matthew Weier O'Phinney
> > Project Lead| matt...@zend.com
> > Zend Framework  | http://framework.zend.com/
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Zend_Application-Bootstrapping-tp23145548p23237042.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


Re: [fw-general] Zend_Application Bootstrapping

2009-04-26 Thread Ehask71


Yeah on my CPanel Webhosting Server I have ZF in the php include path so my
hosting customers dont have to use up all that disk space.   

Eric Haskins



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



Re: [fw-general] Zend_Application Bootstrapping

2009-04-25 Thread gerardroche

In the performance guide it says

"Define your Zend Framework include_path as early as possible

Continuing from the previous suggestion, another obvious optimization is to
define your Zend Framework include_path as early as possible in your
include_path. In most cases, it should be the first path in the list. This
ensures that files included from Zend Framework are found on the first
scan."

If ZF library is set prior to execution and we then set application level
include paths the include_path will read:

1. application level set include_path (application/library)
2. include_path set prior to execution (ZF)

Shouldn't this be the other way round?
Is this a trivial performance cost?

If this is not a trivial performance cost would it good to have an option in
Zend_Application to append application level include paths rather than
prepend them when setting the include path?


Zend_Application lines 227-232

public function setIncludePaths(array $paths)
{
$path = implode(PATH_SEPARATOR, $paths);
set_include_path($path . PATH_SEPARATOR . get_include_path());
return $this;
}

to something like:

public function setIncludePaths(array $paths)
{
$path = implode(PATH_SEPARATOR, $paths);

if ($this->getOption('appendIncludePaths')) {
$includePath = $path . PATH_SEPARATOR . get_include_path();
} else {
$includePath = get_include_path() . PATH_SEPARATOR . $path;
}

set_include_path($includePath);

return $this;
}

we could the set it in our config file.


e.g. ini would read:

includePaths.library = APPLICATION_PATH "/../library"
appendIncludePaths = true




Matthew Weier O'Phinney-3 wrote:
> 
> -- Rob Allen  wrote
> (on Friday, 24 April 2009, 06:23 AM +0100):
>> On 23 Apr 2009, at 23:42, Matthew Weier O'Phinney wrote:
>> > That said, we're seeing some momentum by shared hosts as well as
>> > xAMP stacks to include ZF in the default include_path (Zend Server
>> > falls in this category as well). In such cases, you may be able to
>> > bootstrap  your ZF application and still use your preferred version
>> > of ZF by adding  your include_path.
>> >
>> > One sitation we considered was having Zend_Application add a minimal
>> > include_path to ensure that your ZF include_path includes the path in
>> > which it is found, if that makes sense. Basically, in the constructor,
>> > we'd do something like this:
>> >
>> >$localPath = realpath(dirname(__FILE__) . '/../');
>> >set_include_path($localPath . PATH_SEPARATOR . get_include_path());
>> >
>> > The problem with this is that it's horribly inefficient if you
>> > already have ZF on your include_path, and adds overhead on every
>> > call. We  opted to drop it in order to keep bootstrapping as
>> > performant as possible.
>>
>> Does this imply that you (the ZF team) believe that best practice ZF  
>> sites do not need the library/ directory on their include_path now?
> 
> Not at all. The implications are:
> 
>   * It's better to set your include_path at the vhost (preferred) or
> htaccess (second best) level. For performance reasons, these are the
> better locations.
>   
>   * Having a library/ directory is going to be useful whenever you have
> custom libraries or other 3rd party libraries (including ZF) that
> your application will use.
> 
> The primary implication is quite simply that the include_path should be
> set prior to execution whenever possible.
> 
> -- 
> Matthew Weier O'Phinney
> Project Lead| matt...@zend.com
> Zend Framework  | http://framework.zend.com/
> 
> 

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



Re: [fw-general] Zend_Application Bootstrapping

2009-04-24 Thread Matthew Weier O'Phinney
-- Rob Allen  wrote
(on Friday, 24 April 2009, 06:23 AM +0100):
> On 23 Apr 2009, at 23:42, Matthew Weier O'Phinney wrote:
> > That said, we're seeing some momentum by shared hosts as well as
> > xAMP stacks to include ZF in the default include_path (Zend Server
> > falls in this category as well). In such cases, you may be able to
> > bootstrap  your ZF application and still use your preferred version
> > of ZF by adding  your include_path.
> >
> > One sitation we considered was having Zend_Application add a minimal
> > include_path to ensure that your ZF include_path includes the path in
> > which it is found, if that makes sense. Basically, in the constructor,
> > we'd do something like this:
> >
> >$localPath = realpath(dirname(__FILE__) . '/../');
> >set_include_path($localPath . PATH_SEPARATOR . get_include_path());
> >
> > The problem with this is that it's horribly inefficient if you
> > already have ZF on your include_path, and adds overhead on every
> > call. We  opted to drop it in order to keep bootstrapping as
> > performant as possible.
>
> Does this imply that you (the ZF team) believe that best practice ZF  
> sites do not need the library/ directory on their include_path now?

Not at all. The implications are:

  * It's better to set your include_path at the vhost (preferred) or
htaccess (second best) level. For performance reasons, these are the
better locations.
  
  * Having a library/ directory is going to be useful whenever you have
custom libraries or other 3rd party libraries (including ZF) that
your application will use.

The primary implication is quite simply that the include_path should be
set prior to execution whenever possible.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


Re: [fw-general] Zend_Application Bootstrapping

2009-04-23 Thread Rob Allen


On 23 Apr 2009, at 23:42, Matthew Weier O'Phinney wrote:


That said, we're seeing some momentum by shared hosts as well as xAMP
stacks to include ZF in the default include_path (Zend Server falls in
this category as well). In such cases, you may be able to bootstrap  
your
ZF application and still use your preferred version of ZF by adding  
your

include_path.

One sitation we considered was having Zend_Application add a minimal
include_path to ensure that your ZF include_path includes the path in
which it is found, if that makes sense. Basically, in the constructor,
we'd do something like this:

   $localPath = realpath(dirname(__FILE__) . '/../');
   set_include_path($localPath . PATH_SEPARATOR . get_include_path());

The problem with this is that it's horribly inefficient if you already
have ZF on your include_path, and adds overhead on every call. We  
opted

to drop it in order to keep bootstrapping as performant as possible.


Does this imply that you (the ZF team) believe that best practice ZF  
sites do not need the library/ directory on their include_path now?


Regards,

Rob...




Re: [fw-general] Zend_Application Bootstrapping

2009-04-23 Thread Matthew Weier O'Phinney
-- Steve Reed  wrote
(on Thursday, 23 April 2009, 02:39 PM -0700):
> Matthew Weier O'Phinney-3 wrote:
> > -- Steve Reed  wrote
> > (on Thursday, 23 April 2009, 09:16 AM -0700):
> > > Matthew Weier O'Phinney-3 wrote:
> > > > 
> > > > Zend_Tool generates a public/index.php file, an
> > > > application/Bootstrap.php file, and an
> > > > application/configs/application.ini file. public/index.php pulls in
> > > > Zend_Application, and passes it the path to the configuration file,
> > > > which indicates the include paths and path to the bootstrap class file.
> > > > 
> > > 
> > > Forgive me if I'm missing something obvious here but if I set up my
> > > index.php and application.ini exactly how it specifies in the manual,
> > > I'll
> > > get a fatal error as the Zend/Application.php file cannot be located due
> > > to
> > > the path to the Zend library being added to the include_path by
> > > Zend_Application. I've always set the include_path to the Zend library
> > > (which always resides in my project/library directory) in my index.php
> > > like
> > > so:
> > > 
> > > -
> > > define('APPLICATION_PATH', realpath(dirname(__FILE__) .
> > > '/../application'));
> > > define('LIBRARY_PATH', realpath(APPLICATION_PATH  . '/../library'));
> > > 
> > > defined('APPLICATION_ENV')
> > > || define('APPLICATION_ENV',
> > > (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') :
> > > 'production'));
> > > 
> > > set_include_path(implode(PATH_SEPARATOR, array(
> > > LIBRARY_PATH,
> > > get_include_path()
> > > )));
> > > 
> > > require_once 'Zend/Application.php';
> > > 
> > > $application = new Zend_Application(
> > > APPLICATION_ENV,
> > > APPLICATION_PATH . '/configs/application.ini'
> > > );
> > > $application-> bootstrap();
> > > $application-> run();
> > > -
> > > 
> > > Is the set_include_path call above somehow redunant like it
> > > suggests in the manual? My include_path setting in php.ini is just
> > > ".". Using Zend_Tool to create a project skeleton might answer my
> > > question but, as Rob Allen posted, it's failing in 1.8.0b1 so I
> > > can't test it.
> > 
> > There's an assumption that ZF is already on your vhost's include_path
> > somewhere. Zend_Application allows you to specify additional
> > include_paths specific to your application.
> > 
> > If ZF is *not* on your include_path, you'll need to add it prior to
> > requiring Zend_Application. A good place to do so is your .htaccess or
> > vhost configuration, but you may also specify it in your index.php.
> 
> Is this approach to negate the need to discover the framework for
> application entry points other than index.php? That is scripts and the like.
> It was the following line in the quickstart that partly led to my first
> post:
> 
> includePaths.library = APPLICATION_PATH "/../library"
> 
> Is it not recommended/best practice to put the framework in this directory?
> Therefore it would already be on the include path when bootstrapping? If the
> line is simply to illustrate adding include paths in the config file or
> because the manual hasn't yet been updated then that's cool.

The example is primarily to illustrate how to add an include_path.

That said, we're seeing some momentum by shared hosts as well as xAMP
stacks to include ZF in the default include_path (Zend Server falls in
this category as well). In such cases, you may be able to bootstrap your
ZF application and still use your preferred version of ZF by adding your
include_path.

One sitation we considered was having Zend_Application add a minimal
include_path to ensure that your ZF include_path includes the path in
which it is found, if that makes sense. Basically, in the constructor,
we'd do something like this:

$localPath = realpath(dirname(__FILE__) . '/../');
set_include_path($localPath . PATH_SEPARATOR . get_include_path());

The problem with this is that it's horribly inefficient if you already
have ZF on your include_path, and adds overhead on every call. We opted
to drop it in order to keep bootstrapping as performant as possible.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


Re: [fw-general] Zend_Application Bootstrapping

2009-04-23 Thread Steve Reed



Matthew Weier O'Phinney-3 wrote:
> 
> -- Steve Reed  wrote
> (on Thursday, 23 April 2009, 09:16 AM -0700):
>> Matthew Weier O'Phinney-3 wrote:
>> > 
>> > Zend_Tool generates a public/index.php file, an
>> > application/Bootstrap.php file, and an
>> > application/configs/application.ini file. public/index.php pulls in
>> > Zend_Application, and passes it the path to the configuration file,
>> > which indicates the include paths and path to the bootstrap class file.
>> > 
>> 
>> Forgive me if I'm missing something obvious here but if I set up my
>> index.php and application.ini exactly how it specifies in the manual,
>> I'll
>> get a fatal error as the Zend/Application.php file cannot be located due
>> to
>> the path to the Zend library being added to the include_path by
>> Zend_Application. I've always set the include_path to the Zend library
>> (which always resides in my project/library directory) in my index.php
>> like
>> so:
>> 
>> -
>> define('APPLICATION_PATH', realpath(dirname(__FILE__) .
>> '/../application'));
>> define('LIBRARY_PATH', realpath(APPLICATION_PATH  . '/../library'));
>> 
>> defined('APPLICATION_ENV')
>> || define('APPLICATION_ENV',
>> (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') :
>> 'production'));
>> 
>> set_include_path(implode(PATH_SEPARATOR, array(
>> LIBRARY_PATH,
>> get_include_path()
>> )));
>> 
>> require_once 'Zend/Application.php';
>> 
>> $application = new Zend_Application(
>> APPLICATION_ENV,
>> APPLICATION_PATH . '/configs/application.ini'
>> );
>> $application->bootstrap();
>> $application->run();
>> -
>> 
>> Is the set_include_path call above somehow redunant like it suggests in
>> the
>> manual? My include_path setting in php.ini is just ".". Using Zend_Tool
>> to
>> create a project skeleton might answer my question but, as Rob Allen
>> posted,
>> it's failing in 1.8.0b1 so I can't test it.
> 
> There's an assumption that ZF is already on your vhost's include_path
> somewhere. Zend_Application allows you to specify additional
> include_paths specific to your application.
> 
> If ZF is *not* on your include_path, you'll need to add it prior to
> requiring Zend_Application. A good place to do so is your .htaccess or
> vhost configuration, but you may also specify it in your index.php.
> 
> -- 
> Matthew Weier O'Phinney
> Project Lead| matt...@zend.com
> Zend Framework  | http://framework.zend.com/
> 
> 

Is this approach to negate the need to discover the framework for
application entry points other than index.php? That is scripts and the like.
It was the following line in the quickstart that partly led to my first
post:

includePaths.library = APPLICATION_PATH "/../library"

Is it not recommended/best practice to put the framework in this directory?
Therefore it would already be on the include path when bootstrapping? If the
line is simply to illustrate adding include paths in the config file or
because the manual hasn't yet been updated then that's cool.

Cheers

Steve

P.S. Pats on the back to yourself and Ben Scholzen on this component,
Matthew - 1.8 stable is sure to be an excellent update!
-- 
View this message in context: 
http://www.nabble.com/Zend_Application-Bootstrapping-tp23145548p23204447.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Application Bootstrapping

2009-04-23 Thread Tim Fountain
2009/4/23 Matthew Weier O'Phinney 

>
> There's an assumption that ZF is already on your vhost's include_path
> somewhere.


Is this something that has changed recently? I know Zend_Tool originally
copied the library/Zend folder into 'library' when a new project was
created, but it no longer does this. The current quick start (which I
appreciate won't have been updated for 1.8) suggests users extract the
contents of a ZF download into the library directory.

Personally I don't mind either way, there are advantages and disadvantages
to both approaches, but I can see this confusing users who are new to the
framework.

-- 
Tim Fountain
http://tfountain.co.uk/


Re: [fw-general] Zend_Application Bootstrapping

2009-04-23 Thread Matthew Weier O'Phinney
-- Steve Reed  wrote
(on Thursday, 23 April 2009, 09:16 AM -0700):
> Matthew Weier O'Phinney-3 wrote:
> > 
> > Zend_Tool generates a public/index.php file, an
> > application/Bootstrap.php file, and an
> > application/configs/application.ini file. public/index.php pulls in
> > Zend_Application, and passes it the path to the configuration file,
> > which indicates the include paths and path to the bootstrap class file.
> > 
> 
> Forgive me if I'm missing something obvious here but if I set up my
> index.php and application.ini exactly how it specifies in the manual, I'll
> get a fatal error as the Zend/Application.php file cannot be located due to
> the path to the Zend library being added to the include_path by
> Zend_Application. I've always set the include_path to the Zend library
> (which always resides in my project/library directory) in my index.php like
> so:
> 
> -
> define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
> define('LIBRARY_PATH', realpath(APPLICATION_PATH  . '/../library'));
> 
> defined('APPLICATION_ENV')
> || define('APPLICATION_ENV',
> (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') :
> 'production'));
> 
> set_include_path(implode(PATH_SEPARATOR, array(
> LIBRARY_PATH,
> get_include_path()
> )));
> 
> require_once 'Zend/Application.php';
> 
> $application = new Zend_Application(
> APPLICATION_ENV,
> APPLICATION_PATH . '/configs/application.ini'
> );
> $application->bootstrap();
> $application->run();
> -
> 
> Is the set_include_path call above somehow redunant like it suggests in the
> manual? My include_path setting in php.ini is just ".". Using Zend_Tool to
> create a project skeleton might answer my question but, as Rob Allen posted,
> it's failing in 1.8.0b1 so I can't test it.

There's an assumption that ZF is already on your vhost's include_path
somewhere. Zend_Application allows you to specify additional
include_paths specific to your application.

If ZF is *not* on your include_path, you'll need to add it prior to
requiring Zend_Application. A good place to do so is your .htaccess or
vhost configuration, but you may also specify it in your index.php.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


Re: [fw-general] Zend_Application Bootstrapping

2009-04-23 Thread Steve Reed


Matthew Weier O'Phinney-3 wrote:
> 
> Zend_Tool generates a public/index.php file, an
> application/Bootstrap.php file, and an
> application/configs/application.ini file. public/index.php pulls in
> Zend_Application, and passes it the path to the configuration file,
> which indicates the include paths and path to the bootstrap class file.
> 

Forgive me if I'm missing something obvious here but if I set up my
index.php and application.ini exactly how it specifies in the manual, I'll
get a fatal error as the Zend/Application.php file cannot be located due to
the path to the Zend library being added to the include_path by
Zend_Application. I've always set the include_path to the Zend library
(which always resides in my project/library directory) in my index.php like
so:

-
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('LIBRARY_PATH', realpath(APPLICATION_PATH  . '/../library'));

defined('APPLICATION_ENV')
|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') :
'production'));

set_include_path(implode(PATH_SEPARATOR, array(
LIBRARY_PATH,
get_include_path()
)));

require_once 'Zend/Application.php';

$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();
$application->run();
-

Is the set_include_path call above somehow redunant like it suggests in the
manual? My include_path setting in php.ini is just ".". Using Zend_Tool to
create a project skeleton might answer my question but, as Rob Allen posted,
it's failing in 1.8.0b1 so I can't test it.

Many thanks!
-- 
View this message in context: 
http://www.nabble.com/Zend_Application-Bootstrapping-tp23145548p23197441.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Application Bootstrapping

2009-04-21 Thread Matthew Weier O'Phinney
-- Justin Barnes  wrote
(on Monday, 20 April 2009, 04:43 PM -0500):
> I've begun playing with Zend_Application. I really like the Idea. However I am
> struggling with how to organize the bootstrap and associated files within my
> project. This is my current setup ...
> 
> index.php
> 
> 
> 
> application.php ...
> 
>  
>     // Set the Include path ..
>     // Set the Application configuration ...
>    
>     // Bootstrap
>     require_once 'Zend/Application.php';
>     $application = new Zend_Application($configSection,$applicationConfig);
>     $application->bootstrap();
>     $application->run();
> ?>
> 
> boostrap.php ...
> 
> class Bootstrap extends Zend_Application_Bootstrap_Base
>     {
>  // init functions & dispatch
>     }
> 
> 
> How are others handling this?

Zend_Tool generates a public/index.php file, an
application/Bootstrap.php file, and an
application/configs/application.ini file. public/index.php pulls in
Zend_Application, and passes it the path to the configuration file,
which indicates the include paths and path to the bootstrap class file.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


[fw-general] Zend_Application Bootstrapping

2009-04-20 Thread Justin Barnes
Hello All,

I've begun playing with Zend_Application. I really like the Idea. However I
am struggling with how to organize the bootstrap and associated files within
my project. This is my current setup ...

index.php



application.php ...

bootstrap();
$application->run();
?>

boostrap.php ...

class Bootstrap extends Zend_Application_Bootstrap_Base
{
 // init functions & dispatch
}


How are others handling this?

Thanks