Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil generate module
  • Shouldn't oil be able to generate modules? Something like:
    > php oil generate module <modulename>
    > php oil generate controller <modulename>/<controllername> [<action1> |<action2> |..]
    > php oil generate model <modulename>/<modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..]
    
  • Hi Guys Did anything come of this discussion? I can't find any documentation on creating modules with oil. . . was this functionality ever added?
  • Not that I'm aware off. But you can always just generate it, move it to a module, and add the namespace manually. If this is a feature request, someone has to add it at https://github.com/fuel/oil/issues so it can be followed up. The forum is not the place to ask for features.
  • I think the problem with doing it your way Phil is that it's way too compact. It would force users to have to write it all on one line, which could become really long really fast. How about this:
    > php oil generate module <modulename>
    > php oil generate controller <modulename>\<controllername> [<action1> |<action2> |..]
    > php oil generate model <modulename>\<modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..]
    

  • Thanks, that sounds like a good idea :)
  • I am talking about the same thing as you, but ignoring the "create module" idea as there is no point. Create a module controller or module model, and instead of module/controller you just use controller and pass the module name as an extra option. LOUDLY AGREEING! :)
  • Ahh okay, I see what you meant now. Yep, your way is probably better. Edit: Creating a module through the command line could be helpful. I haven't messed around with modules yet with FuelPHP, but from my understanding (correct me if I'm wrong) each module's path needs to be added to the 'module_paths' config. So it'd be very helpful if we had a oil command that could add the module to the module_paths config, and create all the basic directories in the module.
  • Phil Sturgeon wrote on 03/07/11 1:22 am:
    I am talking about the same thing as you, but ignoring the "create module" idea as there is no point. Create a module controller or module model, and instead of module/controller you just use controller and pass the module name as an extra option. LOUDLY AGREEING! :)
    Yeah, I see where you're coming from. Maybe there could be a point in 'generate module', if it were to act as some sort of setup wizard:
    oil generate module <modulename>
    >> Generate module controller? [y/n]
    y
    >> Enter controller name
    <controllername>
    >> Generate module model? [y/n]
    y
    >> Enter model name
    <modelname>
    

    This would generate a standard module with it's standard directories and create a basic controller and model as well. Then, if you'd want to add another controller later on, you'd simply do 'oil generate controller <modulename>/<controllername>'. Module_paths could also be set by oil to auto activate the module upon generation. Might save us some work :-)
  • Could do. However if we stick to the commands I suggested I can do a:
    if( ! is_dir(APPPATH.'modules/'.\Cli::option('module')))
    {
        // make module skeleton and add to module_paths
    }
    

    No extra work, just make it if it's not there. Does this seem like a good idea?
  • Perfect. Will that allow for custom module paths, or just a convention that the modules dir resides in the app dir?
    oil generate <modulepath>/<modulename>/<controllername>
    

    ? Might add some flexibility
  • Ohh I get you. Perhaps we could do:
    oil g module <modulename> --path <modulepath>

    The path is optional and if provided is set in the config file. Then for all subsequent requests it looks for --module in the normal methods and will look through each of the module paths in turn before it finds a match. And check for duplicates when you create to avoid a clash?
  • Exactly, optional path is indeed what I meant. Sweet solution. I noticed that fuelphp's github issues have been disabled.
    I'm supposed to submit an issue for this here, right? :
    http://dev.fuelphp.com Maybe there could be a link to the dev site, from fuelphp.com/code ?
    Or are you guys not using redmine anymore?
  • I'm trying to think of a good way to do that. The issue is that just doing module/controller means you can't use sub-directory/controller. I think perhaps doing:
    php oil generate --module=<modulename> controller <controllername> [<action1> |<action2> |..]

    The module is just a switch and can go into that command in any order. It means it will just modify the logic and keep the rest of the command the same. Thoughts?

Howdy, Stranger!

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

In this Discussion