Laravel Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4|
Lessons:-Autoloading Classes

18.4 Mapping Underscores
Well we don’t actually need to map the underscore, it’s sitting right there on the keyboard,
always watching, judging… Look I’m sorry underscore, I may abuse you a little but it’s purely
out of love. Camel-casing simply looks wrong to me!
Sorry about that outburst, we will discuss it later in private. The reason that the title is named
mapping underscores is because in ‘ye olde’ days of PHP, before namespaces (and Laravel) had
arrived many developers chose to use underscores within file names to separate sub directories.
Laravel offers the underscored method on the Autoloader to accommodate this type of class
loading. Once more pass an array with the key representing the class prefix and the value
representing the root directory, for example..
1 <?php
2
3 Autoloader::underscored(array(
4 'Paladin' => path('app').'jobs/pld'
5 ));
and now the Class Paladin_Light_Knight will have its definition loaded from the file application/
jobs/pld/light/knight.php.
So now that you know how to auto load your classes with Laravel, you will no longer have to
plaster your source code with include() statements!
I would like to say thanks to Enrique Lopez, who gets to break the character limit because he
was clever enough to comment bilingually. Gracias Enrique!
With Laravel I think what I want and not how to write it. I enjoy programming.
(Con Laravel pienso qué es lo que quiero y no como escribirlo. Me divierto
programando.)

 

 
 
 

osdyui

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)