-2

I'm just new to Kohana and its cascading file system.

From what I understand, using the cascading file system allows extending of core classes and making your module use the subclass in place of the original core class (kind of like monkey patching). What I don't quite understand is why we need to create blank sub classes and put all the logic on Kohana classes. It just seems like a hack and the duplicate classes makes it very hard to trace the calls.

Based from this doc on cascading file system, it will always check for application path first before modules, so is it possible to just completely overwrite the core classes with new versions on the application path? I'm not sure where the blank classes fit in here. An actual concrete example would help, thanks.

gerky
  • 6,267
  • 11
  • 55
  • 82
  • Are you talking about your own classes? You dont need to use blank classes for this (but you can, if you are building library for other users). Those subclasses are useful if you want to change behavior (patch method or add new one) without modifications in original files. – biakaveron Jan 17 '16 at 22:55

1 Answers1

1

I've never really understood the need for the empty classes extending the core Kohana ones either, so you're not alone.

I have often created classes with the same names as the empty ones in order to overwrite them completely. This would be done in either the modules or the application folders.

Kohana compiles the files in this order: system -> modules -> application...so if you were to create a class with the same name within the application directory, it would overwrite any class with the same name in system or modules.

I often create re-usable classes within my own modules and then overwrite certain methods within other modules if I need them to behave slightly differently. You can specify the order that the modules load in by changing your bootstrap.php file in the application directory.

Pretty much the only reason I'm still using Kohana is because of the Hierarchical MVC (HMVC) capabilities, for which I can't seem to find equivalent functionality in any of the other frameworks. It is massively powerful and flexible, especially for large projects.

However, if you are only just getting in to Kohana you may want to reconsider, as it does seem to be a dying framework - the devs seem to have lost interest, which is a real shame because it has so much potential. It is a stable enough framework as it stands though.

Hope this helps you.

SigmaSteve
  • 664
  • 6
  • 25