Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything in PHP like middleman in Ruby?

I've been on a project with a buddy who is leading us with Middleman. We are coding in HAML and SASS and he's obviously a Ruby Dev. I'd like to know if there's ANY type of equivalent for PHP? I'm going to eventually lead a team and I'm much more comfortable with PHP than Ruby.

I'd like to have a layout file (like Zend's layout file) I'd like to...at one command, convert all of the source files from PHP to static HTML and place those static files in a 'build' folder so we can hand it over to the client.

Anyone know of some cool things out there to make this happen? Thanks a bunch!

like image 393
jasonsemko Avatar asked Jan 19 '12 21:01

jasonsemko


2 Answers

A project I work on, www.findbigmail.com, was written completely in PHP to start with and then I did some Ruby/Rails work for a different project, and coming back to PHP was a grind. After using HAML, SCSS and other wonderful things like CSS and JS minify, oh and Compass to build sprites, it was painful to go back to PHP and work again in PHP files with embedded HTML etc.

So, driven by pure slothfulness, I looked around and found MiddleManApp (MM) - after a couple of side trips along the way.

Now we have a very strong separation between what is now a mostly static html site built by MM, with some PHP files that are POSTed to and then redirect back to html pages. Where we need more dynamic behaviour, we've added javascript to the pages and have them call PHP API wrappers around our pre-existing code.

Our site performance has jumped hugely (doh, now its all static html), and its poised to take another jump when the next MiddleMan version comes out with its improved cache-busting abilities inherited from the Rails 3.1 asset pipeline. E.g. we'll be able to reference main.css in our source scripts (which itself is made up of sub-scss files like _index.scss, _pricing.scss) and it will be built with references to main-2348jlk23489kdj.css -- allowing us to set the server to cache for a year and/or deploy many more files to CDN.

Our engineering performance is way up too. We're no longer reluctant to touch UI code for fear of introducing a syntax error into the PHP code. And no more mismatched HTML tags to cause grief. The other PHP developer wasn't familiar with the Ruby/Rails derived toolchain, but has quickly become proficient (though he is a rockstar developer, so that's not too surprising!)

Coming soon is i18n support. Most of that is in MM already and hopefully Javascript support real-soon-now.

We also explored generating pages from HAML with PHP added to them. We decided it was probably quite simple - e.g. add a ":php" tag to the HAML pipeline and then use .php partials as needed. But, we found that between Javascript and wrapping the existing PHP code as an "engine API", we were able to keep the codebases neatly separated -- which we found we prefer overall.

I hope this helps! Happy to explain more.

like image 165
mm2001 Avatar answered Nov 02 '22 06:11

mm2001


There is one for PHP called Piecrust.

I ended up choosing Middleman for the bundled coffeescript, sass, etc., but Piecrust is well done.

http://bolt80.com/piecrust/

like image 45
jevets Avatar answered Nov 02 '22 06:11

jevets