how Class Auto-loading works in joomla 3.0?

563 views
Skip to first unread message

Mayur

unread,
Jul 19, 2012, 12:30:47 AM7/19/12
to joomla-...@googlegroups.com
hi,

how Class Auto-loading working in joomla3.0?

and where we can implement this classes and what is advantages of this class.

Thnaks,
Mayur

Emerson da Rocha Luiz

unread,
Jul 19, 2012, 12:52:01 AM7/19/12
to joomla-...@googlegroups.com
Did you look at documentation? See this  http://developer.joomla.org/platform-manual.html, in special  http://developer.joomla.org/manual/ch01s04.html .

The manual is a bit simple, but works like is explained on it. You must have sure that your classes, folders and filenames follow one specific pattern.

You can also look at source of JPlatform. In special this file  https://github.com/joomla/joomla-platform/blob/staging/libraries/import.php  and, about Joomla "J", this specific line here  https://github.com/joomla/joomla-platform/blob/staging/libraries/loader.php#L279 .

emerson
--
Emerson Rocha Luiz
+55 51 9881-9146
 | Skype: fititnt | GTalk: fititnt | Twitter: @fititnt | http://www.fititnt.org
Membro do JUGRS



--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-cms/-/IuhzWAkQyiYJ.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

Mayur

unread,
Jul 19, 2012, 1:13:00 AM7/19/12
to joomla-...@googlegroups.com
Thanks Emerson,

    yes i see if JLoader  class exist then loader.php include here.

but can you please give me some information about that class. what is benifits of this class.

Thnaks,
Mayur

Mark Dexter

unread,
Jul 19, 2012, 1:16:28 AM7/19/12
to joomla-...@googlegroups.com
The benefit of the autoloader is that you don't have to remember to
use JLoader::register() or jimport for every dependent class for the
class you are writing. As long as the auto loader can find the class
name and file name based on the conventions, the dependent classes are
loaded for you using the built-in lazy loading mechanism of php.
Performance wise, it is just as good to manually register the classes
using JLoader::register(). It's just more work. Mark
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! CMS Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-cms/-/rpQN9N8qDgYJ.

Mayur

unread,
Jul 19, 2012, 1:30:56 AM7/19/12
to joomla-...@googlegroups.com


Thanks Mark

Means if Jloader class execute at once then no need to jimport in each files.

and as you said i think this Jloader class do all work in backend process.

or we can also write some function then call through that Jloader class? 

Thnaks,
Mayur

Mark Dexter

unread,
Jul 19, 2012, 11:44:00 AM7/19/12
to joomla-...@googlegroups.com
If you aren't worried about memory usage, you could simply use
JLoader::register() to register all of your classes once at startup.
As I understand it, the classes aren't loaded until they are needed,
so the only overhead is the ram to keep track of the class list. Mark
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! CMS Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-cms/-/Lk5TbYBSa40J.

Mathew Lenning

unread,
Aug 4, 2012, 2:12:41 AM8/4/12
to joomla-...@googlegroups.com
I just thought I chime in here regarding the naming convention. You don't have to use the default "J" prefix anymore. If you registar your prefix with JLoader and specify what directory to look in then any prefix will work.

=^D

Reply all
Reply to author
Forward
0 new messages