Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Underscores in table names
  • If you ask Oil to generate a scaffold for a table with underscores, it creates subdirectories.
    For example if I have a table "orders" and then later I have one called "order_details" (just an example), and I do oil g scaffold -f order_details ... ... then Oil makes subdirectories controllers/order/ and models/order and puts the generated files there. I like to use underscores in table names in my schema to indicate obvious foreign-key relationships so this is going to happen a lot if I use oil's default behavior, I will get a lot of subfolders in the controller and models - most with just one file in them. Interestingly when it comes to views, it creates a sub-directory "views/order_details" instead of a hierarchy like "view/order/details/". Anyway, should I: a) Stick with the default behavior and get used to it because this hierarchical storage of files is good for me, or
    b) Manually move things around after scaffolding, to have a more flat organization of the files, or
    c) Use table names like "orderdetails" instead of "order_details" so that Oil doesn't create subdirectories in the model & controller areas? Thanks for any opinions/advice!
  • Bump! I have this exact same question. Additionally, regarding the OP's question B, will it break anything in Fuel to move/rename files like that? Thanks in advance for any help or advice!
  • In FuelPHP, an underscore in a name indicates a directory separator in the path, this is how the cascading filesystem and the autoloader work. Instead of moving files around it might be a better option to use a dummy tablename so that everything else is named correctly, and afterwards change the table name in the generated model and migration.
  • It is a bit annoying operation, but the following would be a help for you!

    Thought quite a while since the first post, I hope this would help someone who has just started learning fuelPHP like me.

Howdy, Stranger!

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

In this Discussion