php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15233 Possibility to make include() from within functions with global scope
Submitted: 2002-01-26 06:45 UTC Modified: 2002-10-02 04:04 UTC
Votes:18
Avg. Score:4.8 ± 0.4
Reproduced:18 of 18 (100.0%)
Same Version:3 (16.7%)
Same OS:8 (44.4%)
From: flying at dom dot natm dot ru Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.0.6 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: flying at dom dot natm dot ru
New email:
PHP Version: OS:

 

 [2002-01-26 06:45 UTC] flying at dom dot natm dot ru
 It is very important to have a possibility to perform include() or require() from within a function or class method and have included file into global scope.

 Here is a lot of reasons. Primary one is to make it possible to create dynamically loaded modules, it is very important into large projects. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-10 05:37 UTC] kevin at oceania dot net
for modular installations this type of feature is critical. The alternatives are the code you see produced in *nuke type cms system. I really leaves php lacking
 [2002-06-05 13:29 UTC] tero dot tilus at iki dot fi
I had to change my developement tool due to lack of the possibility to create dynamically loadable (php) modules (with php).  PHP just could't do what I wanted.  Just as Kevin said, this is critical feature in modular systems.
 [2002-06-06 06:44 UTC] tero dot tilus at iki dot fi
Possible (even though not particularily good) workaround is to "register" (put them in say global array, which maps class/function names to filenames) your "dynamic libraries" where you would normally want to load them.  Then where ever you want to access dynamically loaded classes/functions, first include file containing it/them.

This works only when you don't really _have_to_ access global namespace.  I used this approach on a system where config files scattered all over the filesystem (like apache's .htaccess) can locally change behaviour of my system and add features (register new "handlers" etc).  Instead of actually loading these configs only register new features and loading is performed only when I need to instantiate a "dynamically loaded" class.
 [2002-10-02 03:59 UTC] flying at dom dot natm dot ru
This bug was submitted about a year ago, but no any developer comments are still available. According to comments, added by other PHP programmers - this feature is quite important. 
 Will we ever have a chance to know if such funtcionality is planned for implementation?
 [2002-10-02 04:04 UTC] derick@php.net
This is technically almost impossible without rewriting the whole engine.
 [2004-06-25 15:10 UTC] mail at spybreak dot de
> This is technically almost impossible without
> rewriting the whole engine.
Now after two years: same situation for PHP5? I could really use something like this (also for a more modular system).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 23:01:28 2024 UTC