SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile override php.ini to include pear

    hello site

    i wanted to include pear, but actually i don't have access to php.ini on the server. as far as i know i have to edit .htaccess in order to include pearin my application.
    have u got any idea how should i do that?!
    i don't know how to add it to .htaccess...
    and as another question, is it possible to include pear directly in my application. i've done that and i encountered some errors!
    here is the code
    HTML Code:
    [code]ini_set('include_path',/path/to/my/pear'.ini_get('include_path'));  [/code]
    but got this error
    failed to open stream Success in /path/to/my/pear

    thanks in advance
    Last edited by shilan; Aug 20, 2005 at 15:14.

  2. #2
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Less flexible, your .htaccess

    Code:
    phpvalue include_path '/path/to/pear:/other/stuff'
    More flexible, .htaccess

    Code:
    phpvalue auto_prepend_filed '/path/to/initfile.php'
    initfile.php

    PHP Code:
    ini_set('include_path''/path/to/pear:/other/stuff'); 

    The point is that you need to use : to separate the paths. Actually, on windows it's ;
    So, to make it easy, you should use the php constant PATH_SEPARATOR

    After a while, your file could look like:

    PHP Code:
    // define some FRAMEWORK constants
    define('FRAMEWORK_ROOT'realpath(dirname(__FILE__)));
    define('FRAMEWORK_WEB'realpath(FRAMEWORK_ROOT '/pubwww'));
    define('FRAMEWORK_EXT'realpath(FRAMEWORK_ROOT '/ext'));
    define('FRAMEWORK_MODELS'realpath(FRAMEWORK_ROOT '/models'));
    define('FRAMEWORK_VIEWS'realpath(FRAMEWORK_WEB '/views'));

    $include_paths = array('.''..'FRAMEWORK_ROOTFRAMEWORK_WEBFRAMEWORK_EXTFRAMEWORK_MODELSFRAMEWORK_VIEWSget_include_path());
    ini_set('include_path'implode(PATH_SEPARATOR$include_paths)); 

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Including Pear

    No, you don't have to modify anything.
    I had the same situation. My remote server didn't include Pear
    in the installation and I didn't have permissions to change the
    .ini file.

    I made a folder and named it "includes" and put on my doc root.
    Then I just copied the Pear and DB files into it.
    Then in your code at the top use "require" or "include" or "require_once"

    I'm at home right now so I don't have access to any more details but if you
    need more I can reply on Monday.

    It's working great for me.
    Hope this helps.

  4. #4
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Failed opening required 'DB.php'

    thanks alot for your answers

    but still having some problems!
    first i tried to use ini_set, it worked on one host but not on another site, it says: Failed opening required 'DB.php' ('include_path=/path/to/my/pearther/stuff')
    so i tried to edit .htaccess for this one, but everytime i change .htaccess, the whole site would fall in trouble!
    i think that i have problems with merging old values of include_path with new
    path to pear in that file or something about syntax!
    and another question ...

    dear bellcr8v
    u mean that u don't even install pear and u just copy the required classes to a directory, include it and it works?!

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Central Point
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by shilan
    u mean that u don't even install pear and u just copy the required classes to a directory, include it and it works?!
    You don't have to install anything to use the specific classes from pear. The pear thing installed with PHP has other features and it's just a cute little thing to have laying around for ease of use, it's by no means the sole way of using classes.

  6. #6
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've tried to include pear as a class just like other classes
    but i got this error
    Fatal error: Cannot redeclare class pear in /usr/lib/php/PEAR.php on line 86
    what is it about

  7. #7
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you just change your include path you will loose the old one. Instead you should append it.
    PHP Code:
    ini_set('include_path''/path/to/pear'.ini_get('include_path')); 

  8. #8
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've mentioned before that i've used ini_set but the problem still persists.
    be recommendation of Mr. MBaum i used simple require_once but got this error
    Fatal error: Cannot redeclare class pear in /usr/lib/php/PEAR.php on line 86
    what is it about ??


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •