Talk:Pear2 require

From PEAR Wiki

Jump to: navigation, search

Contents

[edit] Quite a few people do not like to install a full installation program on their server just to be able to use one or two packages from PEAR

Then the directory layout within a package needs to be rigidly defined. Currently, a developer can place files anywhere so long as they create roles for each file or directory, making it difficult to "unzip-and-go" predictably with PEAR packages. Changing how files are loaded will not fix this issue.

--weierophinney

this depends heavily on the package, there are so much libraries in the wild working out of the box, this should be fixed by packages, not by an RFC, at least not this way

--Sebastian Mendel 00:09, 19 July 2007 (PDT)

[edit] Are these really problems?

  • PEAR installations are not relocatable. If you move PEAR's installation directory (containing php, data and such), chances are high that the code won't work anymore because of install-time file replacement tasks.

Then PEAR should not rely on hard-coded paths, but instead paths relative to the install directory. Additionally, the methods for manipulating the configuration registry should be well-documented; right now, you have to delve into the class internals. Changing how files are loaded will not fix this issue.

  • PEAR currently uses require_once in nearly each file to include dependencies. This works fine, but is too slow for high-traffic pages for two reasons:
    • require_once needs to traverse the whole include path until it found the correct file. This leads to at least doubled disk usage when searching for the files compared to the single access that is needed if you specify the full path.

This is simply not true in PHP 5.2. PHP has been *fixed* due to reports such as the above. Don't try and solve PHP issues in userland, but instead lobby for fixes in the language.

    • Checking if the file has been included only once is expensive

Again, this may have been true in the past, but is not an issue at this point.

--weierophinney

[edit] A common problem when beginning with PEAR is setting up include path which is required for pear to work at all.

All languages use include paths, and PHP developers should know how to manipulate the include_path setting. Instead of working around the include_path, supplementary documentation should be created to indicate how to use and manipulate it.

--weierophinney

i fully agree! if someone does not know how to setup an include path, he will have much much more problems using pear than just including the libraries ... of course this is not a point against this, but it is also not a point towards this - just better document how to configure this

--Sebastian Mendel 00:25, 19 July 2007 (PDT)

[edit] Have it like it was in PEAR1

this RFC does not describe if the old behaviour should/could still be used:

myPrivateApp.php

<?php
// load class PEAR_MDB2 (pear/ is in include path)
require_once 'MDB2.php';

// use MDB2 and its drivers ...
?>

will this still work?

--Sebastian Mendel 00:14, 19 July 2007 (PDT)

[edit] Include all files at once

"Each package in PEAR2 will have a Package/Name/allfiles.php file that just calls 'require' on every php file the package provides. Using this method, the user will have no problems at all using the package and does not need to setup an include path or an autoloader."

not related to "Quite a few people do not like to install a full installation program on their server just to be able to use one or two packages from PEAR"

not related to "PEAR installations are not relocatable. If you move PEAR's installation directory (containing php, data and such), chances are high that the code won't work anymore because of install-time file replacement tasks."

"PEAR currently uses require_once in nearly each file to include dependencies. This works fine, but is too slow"

not true (anymore) or provide benchmark proofing this

--Sebastian Mendel 00:26, 19 July 2007 (PDT)

Personal tools