note 90078 added to language.oop5.autoload
| From: | roman dot drapeko at gmail dot com | Date: | Sun, 05 Apr 2009 11:33:33 +0000 |
| Subject: | note 90078 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152828@lists.php.net to get a copy of this message | ||
Hi there,
I have developed a small script, that can scan recursively folders and files ang generate array of
associations between classes/interfaces and their locations. It accepts several incoming parameters
and it's very simple to use.
An example of generated array is shown bellow.
<?php
$autoload_list = array (
'classes' => array (
'A' => array ('path' =>
'Project/Classes/Children/A.php',
'extends' => array (), 'implements' => array ('I1')),
'C' => array ('path' => 'Project/Classes/C.php',
'extends' => array ('B'), 'implements' => array
('I1', 'I3')),
),
'interfaces' => array (
'I2' => array ('path' =>
'Project/Interfaces/blablabla.php', 'extends' => array ('I1')),
'I1' => array ('path' => 'Project/Interfaces/I1.php',
'extends' => array ()),
),
);
?>
When you know names and their locations, you know everything to load these classes.
It uses regular expressions to identify if class/interfaces is located in the current file.
I tried to post the code, but it's very long. You can download the script from http://wp.drapeko.com/store/php-autoloading-files/.
----
Server IP: 92.48.74.199
Probable Submitter: 78.86.242.149
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/90078
Del: integrated -- https://master.php.net/note/delete/90078/integrated
Del: useless -- https://master.php.net/note/delete/90078/useless
Del: bad code -- https://master.php.net/note/delete/90078/bad+code
Del: spam -- https://master.php.net/note/delete/90078/spam
Del: non-english -- https://master.php.net/note/delete/90078/non-english
Del: in docs -- https://master.php.net/note/delete/90078/in+docs
Del: other reasons-- https://master.php.net/note/delete/90078
Reject -- https://master.php.net/note/reject/90078
Search -- https://master.php.net/manage/user-notes.php