Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Where to place random classes / libraries
  • Hey, I've read in a tutorial for codeigniter developers, that unlike CI. Everything in FuelPHP is a class. So if I'd want a random class (which would be a library in CI) and I want it to be accessible throughout my entire app, where should i put those? My first thought was in de app/classes/.. folder, but I'm not sure..
  • You're right it would go under app/classes. You can put it inside a sub-folder if you wanted to organise your code.
  • If you put it in a folder of app/classes, remember that the class name has to reflect that.
  • Harro Verton wrote on Thursday 22nd of December 2011:
    If you put it in a folder of app/classes, remember that the class name has to reflect that.

    What do you mean by that?
  • classname = path (fully lowercase, underscores => slashes, + .php) Some_Random_Class = app/classes/some/random/class.php
    RandomClass = app/classes/randomclass.php
    Class = app/classes/class.php
    etc...
  • I see, thanks again.
  • You can write something like this using namespace (using Some_Random_Class as example) namespace Some\Random;
    Class Class {} Class folder is app\classes\some\random
  • Yes, both underscores and namespaces will be converted to dir separators. Thus Some_Random_Class and Some\Random\Class are expected at the same path. Thus it's wise to be very carefull when deciding which to use to prevent ambiguity in your own code.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion