why do we need jimport?

88 views
Skip to first unread message

D. Dante Lorenso

unread,
Jul 20, 2012, 9:39:57 AM7/20/12
to joomla-de...@googlegroups.com
I see this in the Joomla code:

jimport('joomla.filesystem.folder');
JFolder :: create(dirname($file));

But with PHP, we can just autoload classes, so why dont we just have
something like this:

Joomla_Filesystem_Folder :: create(dirname($file));

I don't understand why jimport exists.

-- Dante

D. Dante Lorenso

Michael Babker

unread,
Jul 20, 2012, 9:59:11 AM7/20/12
to joomla-de...@googlegroups.com
It's a leftover from when we couldn't auto load classes. The Platform now has an auto loader and a lot of classes are loaded that way, but there are some classes that don't follow the auto load convention and still need to be manually imported, and that's where jimport still has some use.

-Michael

Please pardon any errors, this message was sent from my iPhone.
> --
> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>

Sam Moffatt

unread,
Jul 20, 2012, 9:59:51 AM7/20/12
to joomla-de...@googlegroups.com
Much of the Joomla Platform was written with support for PHP4 in mind.
Given that PHP5 introduced autoloading, many of the classes and
structures pre-date that functionality. jimport provided a Java
inspired solution for registering files to be loaded in a way that
meant that the system was reasonably flexible.

Increasingly we are shifting to using a camel case based autoloader
for new code however as with any project that has been around for half
a decade and two major PHP versions there is a lot of legacy that
needs to be slowly updated.

Cheers,

Sam Moffatt
http://pasamio.id.au
Reply all
Reply to author
Forward
0 new messages