php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46226 Create new namespace __autoload-type function
Submitted: 2008-10-03 15:35 UTC Modified: 2018-03-25 16:28 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: phpbugs at sevenlight dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 5.3.0alpha2 OS: OSX 10.5.5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-10-03 15:35 UTC] phpbugs at sevenlight dot com
Description:
------------
I suggest adding a new function called __import() or __use() or something similar to autoload namespaces when they are used() but undefined.

Reproduce code:
---------------
core.php
<?php
function __import($sNamespace)
{
    // sample code to load namespace dynamically
    echo "Auto-Importing $sNamespace\n";
    require_once '/path/to/folder/' . join('/', explode('::', $sNamespace) . '.php';
}
?>

some_other_file.php
<?php
namespace MyNamespace;
use Library::DB::Connector;
use Library::Other::Stuff;
?>

Expected result:
----------------
Auto-Importing Library::DB::Connector
Auto-Importing Library::Other::Stuff


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-25 16:28 UTC] cmb@php.net
-Status: Open +Status: Suspended -Package: Feature/Change Request +Package: *General Issues
 [2018-03-25 16:28 UTC] cmb@php.net
This feature would require the RFC process[1].  Anybody is welcome
to start it.  For the time being, I'm suspending this ticket.

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Oct 27 12:01:22 2020 UTC