Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
'use Orm\Model' vs FuelPHP Docs mismatch
  • Hi there.
    After generating some scaffolding for "message", I looked at the Model source, and checked this against the ORM Documentation.
    It appears there is a slight difference: My generated scaffold model.
    use Orm\Model;
    
    class Model_Message extends Model
    {
    
    The PHPFuel docs. http://docs.fuelphp.com/packages/orm/creating_models.html
    class Model_Article extends Orm\Model
    
    As you can see, the "Orm\Model" is setup differently.
    Is this a problem with scaffolding using old templates and which one am I supposed to use? Any help on clearing this up would be great, thank you!
  • Those mean the exact same thing, you can read up on namespaces on php.net.
  • Thank you, yes.
    But I meant more along the lines of - "Why is the scaffold, going against the recommended procedure in the docs?"
    I thought perhaps it was a preferred method, or out of date, for example.
  • There is no recommendation, it's a matter of personal preference. We are moving toward using 'use' for 2.0, but as with a lot of things FuelPHP, there is more then one way to skin a cat. Not all possible solutions are documented.
  • To add a little bit to that: when developing 1.0 we were a bit careful of using namespaces too much out of fear of scaring people off. In this case the choice for either isn't all that interesting. I'd use Orm\Model as there's also a Model class in global, thus using it as Orm\Model makes your code a bit less ambiguous. But that is specific to this example and not a general recommendation. With 2.0 I tend to have little to no classes called using a backslash prefix, and thus having use statements for each class or namespace. Whether I import the class directly into the current namespace or only import its namespace and call it with that included depends on clarity: whether I still understand what the class is about without the namespace.

Howdy, Stranger!

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

In this Discussion