Jump to content

PW Best Practices: Application Structure (form handling)


alexeld
 Share

Recommended Posts

Hi folks,

I'm new to ProcessWire, and I'm currently evaluating it for use in an upcoming project. The reviews and write-ups I've read online have said great things about it, and from what I've seen so far, I'm really rather impressed.

I've spent a lot of time using Laravel, CodeIgniter, and CakePHP, all of which make use of the MVC pattern, however, PW doesn't do this, and therefore I'm looking for some advice on how best to structure my PW applications...

Reading around, I've found some write-ups which cover form handling and validation, but I'm unsure quite *where* these files should live, and I'd love some advice on how best to structure my application. Do I create a template which contains form-handling code *and* HTML (all in the same file -- like "classic PHP"), or can I separate my form handler/validation code from my markup (and have the HTML form post to a PHP script somewhere else)? Or maybe there's another way (perhaps using Modules) that I'm unaware of?

If it helps, I'm /usually/ the "backend guy" on the projects I tend to work on, and I work closely with front-end chaps (designers mostly) who throw together the HTML, so if there is a way to keep the markup and processing logic loosely coupled, I'd love to hear about it!

Anyway, thanks for taking the time to read this, and I really would appreciate any wisdom you kind people have to offer.

Many thanks!

  • Like 1
Link to comment
Share on other sites

I've spent a lot of time using Laravel, CodeIgniter, and CakePHP, all of which make use of the MVC pattern, however, PW doesn't do this, and therefore I'm looking for some advice on how best to structure my PW applications...

Since you are comfortable with using the MVC pattern, this may be the way you want to go in ProcessWire too. ProcessWire is very much supportive of the MVC pattern, it's just that it doesn't require it. ProcessWire is providing your models, your template files provide your controllers, and you provide the views with the TemplateFile class (or some other view loader of your own if preferred). You can also choose to target some template files/pages as views and call $page->render() on them. If you are interested, the Blog profile does use an MVC-style approach and would be worth looking at. But after you spend some time with ProcessWire, I recommend finding the approach that best suits a particular situation rather than locking yourself down to using the same one all the time. ProcessWire is giving you a lot more in some areas than a typical MVC framework does, so you may find even faster and more maintainable ways to structure your code, depending on the situation.

  • Like 4
Link to comment
Share on other sites

Hi Chaps,

First of all: thank you all ever-so much for getting back to me! There's a mountain of great advice from each of you for me to start working through, and I really do appreciate it. 

 ... after you spend some time with ProcessWire, I recommend finding the approach that best suits a particular situation rather than locking yourself down to using the same one all the time.

I had started to get a sense that ProcessWire was accommodating of various development methods, and it's actually quite refreshing to find a framework which *doesn't* enforce a strict development methodology. Suffice it to say, I'm looking forward to getting stuck in to developing my little test application to figure out which method here best suits my needs.

You guys have been great. Thanks again for all the input!

Cheers!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...