Phreeze

Phreeze: how to get it set up and running

Phreeze is an amazing application generator which allows to have an entire database management application built just in minutes.

Sometime ago I was working for a customer who, for reasons I couldn’t know, didn’t want give me a full access to his hosting provide control panel. That’s was not a big issue: in fact I could do the most part of work just using an FTP client. But the database management was difficult having to always give sql dump files to my customer and then wait that he performed the queries against the database.

I couldn’t even use a remote database management software like MySql Workbench, because the hosting provider didn’t allow that.

So I have finally decided to look for a solution which give me a workaround to all these difficulties and allowed me to directly perform all CRUD operations without having to interact with the customer. This way I have discovered Phreeze.

As authors say:

Phreeze is a framework for building PHP applications. A framework is basically a toolkit of helper classes along with a consistent application structure.

Phreeze is comprised of three components. The one we’ll look at in this small guide is Phreeze Builder:

…is a utility that analyzes a database and auto-generates a basic application that is ready to use and/or customize.

What I want is just to show you how to build  a basic database management application with Phreeze Builder, beacuse it tooke me a bit of time before to get it working (probably because I’m a bit stupid, but we can ignore that for the moment…)

Getting started

First, go to https://github.com/jasonhinkle/phreeze and download the compressed file to your machine, then uncompress it in a convenient location.

You should now have in your target directory a folder called phreeze-master which holds all application files: I suggest you to rename it to phreeze (just to avoid issues with internal links) and to upload it to your server (let’s call it www.mydomain.com).

Now, use your browser of choice to visit www.mydomain.com/phreeze/builder.

If you get some error (as it happened to me), you have to open the .htaccess you find in phreeze/builder directory and uncomment the
RewriteBase rule, that is replace this line:

#RewriteBase /phreeze/builder/

with this one:

RewriteBase /phreeze/builder/

Maybe you still get an error about timezone settings: if this is the case, open in your code editor the file phreeze/builder/_machine_config.php and uncomment following line

//date_default_timezone_set("UTC");

in order to have:

date_default_timezone_set("UTC");

Running the Builder

Now navigating to http://www.mydomain.com/phreeze/builder you should correctly access the builder wizard. In the first page you have to put your connection data: database host, username, password, database name and the type of mysql connection (mysql, mysqli or PDO).

Phreeze BuilderWhen you have done, just click Analyze Database button.

Using the Analyzer

The next page shows you a complete list of your database tables (if you don’t want some table be managed by your application, just uncheck it) and ask you to adjust some more settings:

Phreeze AnalyzerHover your mouse over the question marks to get a quick and clear explanation of the option; below I report them here showing my settings:

[embedit snippet=”phreeze-options”]

If you want to know how to build an accordion like this one with a few lines of code you can read my article The simplest jQuery Accordion ever!

Generating the application

And now we can finally click the Generate application button. Depending on the size of your database, after some time your browser will download an archive with your application. Uncompress this archive in the choosen directory (in our example it was ‘db_admin’, do you remember?).

I’ts almost done. We have just to repeat some steps we did above to configure Phreeze Builder:

  1. open the .htaccess file in your /db_admin/ directory and set the value of RewriteBase rule correctly: RewriteBase /dbman/
  2. then open the _machine_config.php file in your /db_admin/ directory and set the timezone: date_default_timezone_set(“UTC”);

Now you can visit the URL  www.mydomain.com/db_admin and start to manage your database!

Warning. Browsing through your database you could find that not always table has all columns you would expect to see: that’s strange and it took me a bit to discover the issue. Since I’m a generous man, I want to reveal the secret right now! By default, Phreeze applications doesn’t show more than 5 columns per table. To change this, you have to open /db_admin/templates/ directory and look for the template which refers to the table you want to show more columns (virtually all of them) and open it in you code editor of choice. Around line 30 you’ll find something like this:

	<!-- underscore template for the collection -->
	<script type="text/template" id="ftThemesCollectionTemplate">
		<table class="collection table table-bordered table-hover">
		<thead>
			<tr>
				<th id="header_Column1">Column11<% if (page.orderBy == 'Column1') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
				<th id="header_Column2">Column12<% if (page.orderBy == 'Column2') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
				<th id="header_Column3">Column3<% if (page.orderBy == 'Column3') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
				<th id="header_Column4">Column4<% if (page.orderBy == 'Column4') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
				<th id="header_Column5">Column5<% if (page.orderBy == 'Column5') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
<!-- UNCOMMENT TO SHOW ADDITIONAL COLUMNS
				<th id="header_Column6">Column6<% if (page.orderBy == 'Column6') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
				<th id="header_Column7">Column7<% if (page.orderBy == 'Column7') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
				<th id="header_Column8">Column8<% if (page.orderBy == 'Column8') { %> <i class='icon-arrow-<%= page.orderDesc ? 'up' : 'down' %>' /><% } %></th>
-->
			</tr>
		</thead>
		<tbody>
		<% items.each(function(item) { %>
			<tr id="<%= _.escape(item.get('Column1')) %>">
				<td><%= _.escape(item.get('Column1') || '') %></td>
				<td><%= _.escape(item.get('Column2') || '') %></td>
				<td><%= _.escape(item.get('Column3') || '') %></td>
				<td><%= _.escape(item.get('Column4') || '') %></td>
				<td><%= _.escape(item.get('Column5') || '') %></td>
<!-- UNCOMMENT TO SHOW ADDITIONAL COLUMNS
				<td><%= _.escape(item.get('Column6') || '') %></td>
				<td><%= _.escape(item.get('Column7') || '') %></td>
				<td><%= _.escape(item.get('Column8') || '') %></td>
-->
			</tr>
		<% }); %>
		</tbody>
		</table>

		<%=  view.getPaginationHtml(page) %>
	</script>

Okay: just do what they say and “UNCOMMENT TO SHOW ADDITIONAL COLUMNS” 🙂

Hope this help

2 thoughts on “Phreeze: how to get it set up and running”

Leave a Comment

Your email address will not be published. Required fields are marked *