www.webdeveloper.com
Results 1 to 5 of 5

Thread: Make php functions available to all apps

  1. #1
    Join Date
    Dec 2008
    Posts
    488

    Question Make php functions available to all apps

    I was setting up CakePHP yesterday and I passed over something about making the CakePHP libraries available to all applications by copying them to some folder, but I can't find it in the manual now.

    I'm not wanting to necessarily do it with CakePHP, but with my own UDFs. Where do I place these functions? Do I put them in the extensions folder and then enable them in the php.ini? Or do I just have to require() them?

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    You can auto-include certain libraries with the PHP auto_prepend_file directive. However, it's probably a better practice to either explicitly include()/require() files as needed or to use class autoloading.
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,312
    As far as I know you would just have to require() the relevant files. Where the files are should not matter, other than you might want them in your PHP include_path (or change the include_path setting to point to wherever they are).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Nov 2008
    Posts
    2,477
    Cake does it by simply defining the location of the cake library as a constant and building include paths using that. As mentioned above the cake core still uses require/include and class autoloading as normal - using a library location constant just allows the core to be shared by many apps.

  5. #5
    Join Date
    Dec 2008
    Posts
    488
    I see. This makes sense. I didn't realize it was targeted towards other cake apps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles