How to bend PHP to my ASP.NET desires
December 29, 2009 9:23 AM   Subscribe

What frameworks or modules exist to allow PHP to function similar to ASP.NET? Specifically I am talking about the following ...
  • Separating code from design
  • Maintaining page and HTML element state between postbacks

As a web developer, I program in ASP.NET/ MS SQL Server for work and have done so for many years. I am learning PHP and MySQL in order make myself more marketable and because it is cheaper to develop and host PHP and MySQL web applications. I love the XAMPP/WAMP stacks and how portable they are. I can run it right from a USB stick. Can't do that with IIS, SQL Server and the .NET runtime.

I know PHP is very powerful as I can see how well the WordPress and Drupal frameworks work (just to name a few). There are many development paradigms that ASP.NET makes use of that I would be surprised to find did not exisit within PHP modules or frameworks.

Separating code from design - Allowing for code to be kept separately and away from UI elements. ASP.NET does this via "code behind".

Maintaining page state between postbacks - Sure you can code this manually in PHP but there must be another way to maintain page state than coding it all by hand.

I don't mean for this to be a ASP.NET vs PHP rant. Quite the opposite I can see that PHP is a very serious development tool. Rather I am just looking for advice on how PHP has addressed some of the same issues ASP.NET has.
posted by mountainfrog to Technology (6 answers total) 3 users marked this as a favorite
I think you're going to have a hard time with your first requirement- it's one of the key benefits of .NET and JSP, and PHP just isn't built to work that way.

That said, an MVC framework for PHP might get you at fair way down that road. Have you tried some of the more popular frameworks like CakePHP?
posted by mkultra at 9:38 AM on December 29, 2009

Seconding CakePHP:
It will get you most of the way there.
Cake does pretty well at emulating Rails. But why just PHP and MySql? Learning Python or Ruby (along with Django or Rails) might suit you as well. IMHO those languages/frameworks are a lot better suited to MVC frameworks and good stuff like seperation of business logic/presentation.
posted by gunslingingbird at 10:32 AM on December 29, 2009

Zend Framework
posted by AlsoMike at 10:37 AM on December 29, 2009

There's also the Symfony Framework which is modeled fairly closely to Rails.

Just avoid Zend. It's been awhile since I've had to (shudder) use it, but I don't have anything good to say about it.
posted by jacquilinala at 10:48 AM on December 29, 2009

Smarty pretty much nails your first requirement.
posted by xmutex at 10:53 AM on December 29, 2009

Seconding The Smarty templating engine.

You will hate it. You will hate the templating syntax and its odd idiosyncrasies. And then, suddenly, you will love it.

Cake and other MVC engines will help you abstract/architect code. But nothing's better than Smarty for separating your PHP code from your design.
posted by lexfri at 10:59 AM on December 29, 2009

« Older How do I fix what foundation repair broke?   |   cant decide Newer »
This thread is closed to new comments.