On Wed, Nov 9, 2011 at 2:03 PM, Anthony Ferrara <ircmax...@gmail.com> wrote: > Rafael > >> This makes life as a PHP developer much easier and having the standard> >> "valued" by PHP by having a SplClassLoader that allows any library to> not >> need to implement a autolaoder if no framework is present allows> for much >> nicer "plug and play" interaction of libraries, less work for> their >> developers and even less for the users. > > I would have to disagree here. When I need to use a library or a > framework or whatever, I usually just bootstrap it and done. So > instead of having to care about figuring out how to map the > namespaces, or place them appropriately, I just call the included > bootstrap.php in the library and it does the rest. You can take a > peak at an example of that here: > https://github.com/ircmaxell/PHP-CryptLib/blob/master/lib/CryptLib/bootstrap.php >
You sort of prove my point here, as you actually have your own autoloader, which in case you are PSR compliant, you would not need, you can still use your bootstrap but no longer implement the class. Also bootstrapping is not a solution for smaller libraries that include one or 2 classes, having to code an autoloader for everything is redundant. And frankly having to make sure you do requires to get the loaders is something i would rather get rid of. The day i can code a whole application without a single require in it will be a blast. > If you're going for ease of use and interoperability, providing a > bootstrap file is going to be king to any autoloader/naming scheme. > Some libraries may have specific steps that it needs to do at startup > to work. That's what a bootstrap is for. Some libraries may need to > include and define functions or constants. That's what a bootstrap is > for. This depends on the size of your library, bootstrapping might not be a requirement, and from what i see around its actually used very little. Anything needed is attached to your application or is done in the construct methods. > Remember, libraries are more than collections of classes. They may > contain other things that autoloading just doesn't take care of. Libraries can be more the collections of classes, or they can be just collection of classes. Either way my comment was directed to both cases. > Sure, the thought of just being able to add it to an autoloader to > take care of including the library may suffice for 90% of use cases. > But it won't work (or won't work well) enough times that I'm not sure > if it's even worth trying to reach for that goal. > Thanks, > > Anthony Bootstrapping and autoloading are two parts of a process, having one done better does not exclude having the other in your library. So a see bootstrapping as a form of configuration and preparation, autoloading is merely a step that may or may not be in this. -- Rafael Dohms PHP Evangelist and Community Leader http://www.rafaeldohms.com.br http://www.phpsp.org.br -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php