Using HTML5 Boilerplate Build script with a PHP framework
-
27-10-2019 - |
Question
I’m a big fan of the popular HTML5 Boilerplate. I’d love to use the build script to minifiy etc, but I can’t figure out how to get everything working together. To add further fun, I deploy using Git – no FTP.
Paul Irish’s video on using the build script is great, and at the end he shows a way to deploy on a server, then use .htaccess to reroot traffic from .com/ to .com/published/site/ – however that doesn’t really work when you’ve got a webapp and you’re using views. It’s also a really bad habit to put any code in public_html.
So here’s the structure I’m after of the deployed and built site:
- webapp
- app
- classes
- welcome.php
- views
- template.php
- framework
- public_html
- index.php
- css
- js
- img
But it needs to:
- Be still able to develop locally, without having to build every time!
- Be Gitable – deploy to server, then build
- Minify and read views from webapp
My first attempt ended up like this:
- webapp
- app
- classes
- welcome.php
- views
- template.php
- framework
- public_html
- index.php
- css (minified)
- js (minified)
- img (minified)
- dev_html
- index.php
- build
- etc...
- css
- js
- img
Then I published back up, but then completely forgot about the fact that the HTML file that needs reading is in the webapp, so then I get stuck.
It’s a bit complicated so do ask if you don’t get it!
Solution
Michell’s suggestion of using CodeIgniter/HTML5 Boilerplate by Serkan Sökmen is pretty close, but the problem is that it publishes it to a folder within itself, which if you published on a server (after deploy via Git), would mean the app is in public_html – bad for security.
I’ve started a topic about it in the issues at HTML5 Boilerplate if anybody’s interested. Not figure it out yet: https://github.com/h5bp/html5-boilerplate/issues/558
Edit! Updated!
I’ve created a GitHut repo for the files I’ve changed: https://github.com/thomasedwards/h5bp-publish-tree
It pretty much works the way I intended it to, might be worth something to somebody.
OTHER TIPS
Since your using Git anyway, check out Serkan Sökmen's github branch where he's got CI and HTML5 Boilerplate working together: Codeigniter---HTML5-Boilerplate