Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How can I prevent Oil from overwriting my base controller?
  • When I run:

    $ oil g admin clients name:string licensee_limit:int

    Oil is throwing:

    Error: /project/fuel/app/classes/controller/base.php already exists, use -f or --force to override

    If I --force the issue, it overwrites my base controller. How can I prevent this? I have a bunch of admin interfaces that I need to generate, and they all need to extend my already existing base controller. Am I going about this the wrong way?
  • I just realized that it overwrote my admin controller too. Luckily I'm using git, so I didn't completely hose everything, but clearly I'm doing this completely wrong.
  • I did some research but couldn't find anything about the oil g admin command. I'm assuming that it creates the basic admin interface and extends the base controller, basically like scaffold except with those extra controllers generated. If I use:

    $ oil g scaffold admin_clients name:string licensee_limit:int

    it doesn't try to regenerate my base or admin controllers. It doesn't extend the proper controller by default, but that's easy enough to fix by hand.

    On a side note: it would be nice if oil had an option to generate namespaced code instead of using the old Controller_ and Model_ style syntax.
  • HarroHarro
    Accepted Answer
    You can use --skip to skip over already existing files when generating new ones.
  • Controller_ and Model_ are the default naming conventions of these files.

    For Models, you could use the namespace "Model" without problems, but for controllers that is not going to work without configuration.
  • Thanks Harro. I found the code within the oil package that needs to be changed to generate \Controller\ prefixed code rather than Controller_.

Howdy, Stranger!

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

In this Discussion