5

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!

jasonsemko
  • 743
  • 1
  • 7
  • 17
  • Try jumping out of your comfort zone every once in a while... you'll be glad you did! – Mark Thomas Jan 19 '12 at 23:27
  • 1
    I never used Ruby , but are you looking for a static site generator like http://www.phrozn.info/en/ , if I am right I will make it as answer :) – Hari K T Jan 20 '12 at 04:51

3 Answers3

4

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.

mm2001
  • 6,427
  • 5
  • 39
  • 37
  • Can you elaborate slightly on how to "POST to and then redirect back to html pages"? – Bradley Trager Aug 29 '13 at 17:01
  • Sure. In the static html we have a
    , say, and it has a POST that goes to a url that is PHP. Then, in the PHP code, we do whatever processing is needed, and then in PHP we call header('Location: ' . $urlTo); where $urlTo is set to one of the static HTML pages.
    – mm2001 Dec 06 '13 at 23:39
2

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/

jevets
  • 23
  • 3
0

PHP can render static HTML from PHP code quite easily:

Easiest way to convert a PHP page to static HTML page

Generate HTML Static Pages from Dynamic Php Pages

PHP - How to programmatically bake out static HTML file?

You could wire up something with existing template systems like Twig or use PHP Markdown to more or less mimic what Middleman is doing and create static HTML pages from your source files.

EDIT: As Hari K T mentioned above, http://www.phrozn.info/en/ does exactly this.

Community
  • 1
  • 1
Darren Newton
  • 2,847
  • 1
  • 29
  • 31