{"id":156,"date":"2017-09-07T11:58:43","date_gmt":"2017-09-07T11:58:43","guid":{"rendered":"https:\/\/codingfix.com\/?p=156"},"modified":"2018-07-12T12:18:09","modified_gmt":"2018-07-12T12:18:09","slug":"phreeze-build-basic-crud-application","status":"publish","type":"post","link":"https:\/\/codingfix.com\/phreeze-build-basic-crud-application\/","title":{"rendered":"Phreeze: how to get it set up and running"},"content":{"rendered":"<p>Phreeze is an amazing application generator which allows to have an entire database management application built just in minutes.<\/p>\n<p>Sometime ago I was working for a customer who, for reasons I couldn&#8217;t know, didn&#8217;t want give me a full access to his hosting provide control panel. That&#8217;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.<\/p>\n<p>I couldn&#8217;t even use a remote database management software like MySql Workbench, because the hosting provider didn&#8217;t allow that.<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/phreeze.com\/phreeze\/documentation\/introduction.php\" target=\"_blank\" rel=\"noopener\">As authors say<\/a>:<\/p>\n<blockquote><p>Phreeze is a framework for building PHP applications. A framework is basically a toolkit of helper classes along with a consistent application structure.<\/p><\/blockquote>\n<p>Phreeze is comprised of three components. The one we&#8217;ll look at in this small guide is <em>Phreeze Builder:<\/em><\/p>\n<blockquote><p>&#8230;is a utility that analyzes a database and auto-generates a basic application that is ready to use and\/or customize.<\/p><\/blockquote>\n<p>What I want is just to show you how to build\u00a0 a basic database management application with Phreeze Builder, beacuse it tooke me a bit of time before to get it working (probably because I&#8217;m a bit stupid, but we can ignore that for the moment&#8230;)<\/p>\n<h2>Getting started<\/h2>\n<p>First, go to <a href=\"https:\/\/github.com\/jasonhinkle\/phreeze\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/jasonhinkle\/phreeze<\/a> and download the compressed file to your machine, then uncompress it in a convenient location.<\/p>\n<p>You should now have in your target directory a folder called <em>phreeze-master<\/em> which holds all application files: I suggest you to rename it to <em>phreeze<\/em> (just to avoid issues with internal links) and to upload it to your server (let&#8217;s call it www.mydomain.com).<\/p>\n<p>Now, use your browser of choice to visit <em>www.mydomain.com\/phreeze\/builder<\/em>.<\/p>\n<p>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<br \/>\n<strong>RewriteBase<\/strong> rule, that is replace this line:<\/p>\n<pre class=\"theme:github toolbar:2 striped:false marking:false ranges:false nums:false nums-toggle:false wrap-toggle:false plain:false plain-toggle:false copy:false popup:false expand-toggle:false lang:default decode:true\">#RewriteBase \/phreeze\/builder\/<\/pre>\n<p>with this one:<\/p>\n<pre class=\"theme:github toolbar:2 nums:false nums-toggle:false wrap-toggle:false plain:false plain-toggle:false copy:false popup:false expand-toggle:false lang:default decode:true\">RewriteBase \/phreeze\/builder\/<\/pre>\n<p><strong>Maybe you still get an error about timezone settings<\/strong>: if this is the case, open in your code editor the file <em>phreeze\/builder\/_machine_config.php<\/em> and uncomment following line<\/p>\n<pre class=\"theme:github toolbar:2 nums:false nums-toggle:false wrap-toggle:false plain:false plain-toggle:false copy:false popup:false expand-toggle:false lang:default decode:true\">\/\/date_default_timezone_set(\"UTC\");<\/pre>\n<p>in order to have:<\/p>\n<pre class=\"theme:github toolbar:2 nums:false nums-toggle:false wrap-toggle:false plain:false plain-toggle:false copy:false popup:false expand-toggle:false lang:default decode:true\">date_default_timezone_set(\"UTC\");<\/pre>\n<h2>Running the Builder<\/h2>\n<p>Now navigating to\u00a0<em>http:\/\/www.mydomain.com\/phreeze\/builder<\/em> 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).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-197 size-large\" src=\"https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_builder-1-1024x624.png\" alt=\"Phreeze Builder\" width=\"1024\" height=\"624\" srcset=\"https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_builder-1-1024x624.png 1024w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_builder-1-600x365.png 600w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_builder-1-300x183.png 300w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_builder-1-768x468.png 768w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_builder-1.png 1228w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/>When you have done, just click <em>Analyze Database<\/em> button.<\/p>\n<h2>Using the Analyzer<\/h2>\n<p>The next page shows you a complete list of your database tables (<em>if you don&#8217;t want some table be managed <\/em><em>by your application, just uncheck it<\/em>) and ask you to adjust some more settings:<\/p>\n<p><a href=\"https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-219 size-large\" src=\"https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer-1024x673.png\" alt=\"Phreeze Analyzer\" width=\"1024\" height=\"673\" srcset=\"https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer-1024x673.png 1024w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer-600x394.png 600w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer-300x197.png 300w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer-768x505.png 768w, https:\/\/codingfix.com\/wp-content\/uploads\/2017\/09\/phreeze_analyzer.png 1236w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a>Hover your mouse over the question marks to get a quick and clear explanation of the option; below I report them here showing my settings:<\/p>\n<p><b>[embedit snippet=&#8221;phreeze-options&#8221;] <\/b><\/p>\n<p><span style=\"font-size: 10pt;\"><em>If you want to know how to build an accordion like this one with a few lines of code you can read my article <a href=\"https:\/\/codingfix.com\/simplest-jquery-accordion-ever\/\">The simplest jQuery Accordion ever!<\/a><\/em><\/span><\/p>\n<h2>Generating the application<\/h2>\n<p>And now we can finally click the <em>Generate application<\/em> 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 &#8216;db_admin&#8217;, do you remember?).<\/p>\n<p>I&#8217;ts almost done. We have just to repeat some steps we did above to configure Phreeze Builder:<\/p>\n<ol>\n<li>open the <em>.htaccess<\/em> file in your <em>\/db_admin\/<\/em> directory and set the value of RewriteBase rule correctly: <span class=\"theme:github lang:default decode:true crayon-inline \">RewriteBase \/dbman\/<\/span><\/li>\n<li>then open the <em>_machine_config.php<\/em> file in your <em>\/db_admin\/<\/em> directory and set the timezone: <span class=\"theme:github lang:default decode:true crayon-inline \">date_default_timezone_set(&#8220;UTC&#8221;);<\/span><\/li>\n<\/ol>\n<p>Now you can visit the URL\u00a0 <em>www.mydomain.com\/db_admin<\/em> and start to manage your database!<\/p>\n<p><strong>Warning.<\/strong> Browsing through your database you could find that not always table has all columns you would expect to see: that&#8217;s strange and it took me a bit to discover the issue. Since I&#8217;m a generous man, I want to reveal the secret right now! By default, Phreeze applications doesn&#8217;t show more than 5 columns per table. To change this, you have to open <em>\/db_admin<\/em>\/<em>templates\/<\/em> 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&#8217;ll find something like this:<\/p>\n<pre class=\"theme:github lang:default decode:true\">\t&lt;!-- underscore template for the collection --&gt;\r\n\t&lt;script type=\"text\/template\" id=\"ftThemesCollectionTemplate\"&gt;\r\n\t\t&lt;table class=\"collection table table-bordered table-hover\"&gt;\r\n\t\t&lt;thead&gt;\r\n\t\t\t&lt;tr&gt;\r\n\t\t\t\t&lt;th id=\"header_Column1\"&gt;Column11&lt;% if (page.orderBy == 'Column1') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;th id=\"header_Column2\"&gt;Column12&lt;% if (page.orderBy == 'Column2') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;th id=\"header_Column3\"&gt;Column3&lt;% if (page.orderBy == 'Column3') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;th id=\"header_Column4\"&gt;Column4&lt;% if (page.orderBy == 'Column4') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;th id=\"header_Column5\"&gt;Column5&lt;% if (page.orderBy == 'Column5') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n&lt;!-- UNCOMMENT TO SHOW ADDITIONAL COLUMNS\r\n\t\t\t\t&lt;th id=\"header_Column6\"&gt;Column6&lt;% if (page.orderBy == 'Column6') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;th id=\"header_Column7\"&gt;Column7&lt;% if (page.orderBy == 'Column7') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n\t\t\t\t&lt;th id=\"header_Column8\"&gt;Column8&lt;% if (page.orderBy == 'Column8') { %&gt; &lt;i class='icon-arrow-&lt;%= page.orderDesc ? 'up' : 'down' %&gt;' \/&gt;&lt;% } %&gt;&lt;\/th&gt;\r\n--&gt;\r\n\t\t\t&lt;\/tr&gt;\r\n\t\t&lt;\/thead&gt;\r\n\t\t&lt;tbody&gt;\r\n\t\t&lt;% items.each(function(item) { %&gt;\r\n\t\t\t&lt;tr id=\"&lt;%= _.escape(item.get('Column1')) %&gt;\"&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column1') || '') %&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column2') || '') %&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column3') || '') %&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column4') || '') %&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column5') || '') %&gt;&lt;\/td&gt;\r\n&lt;!-- UNCOMMENT TO SHOW ADDITIONAL COLUMNS\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column6') || '') %&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column7') || '') %&gt;&lt;\/td&gt;\r\n\t\t\t\t&lt;td&gt;&lt;%= _.escape(item.get('Column8') || '') %&gt;&lt;\/td&gt;\r\n--&gt;\r\n\t\t\t&lt;\/tr&gt;\r\n\t\t&lt;% }); %&gt;\r\n\t\t&lt;\/tbody&gt;\r\n\t\t&lt;\/table&gt;\r\n\r\n\t\t&lt;%=  view.getPaginationHtml(page) %&gt;\r\n\t&lt;\/script&gt;<\/pre>\n<p>Okay: just do what they say and &#8220;UNCOMMENT TO SHOW ADDITIONAL COLUMNS&#8221; \ud83d\ude42<\/p>\n<p>Hope this help<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t know, didn&#8217;t want give me a full access to his hosting provide control panel. That&#8217;s was not a big issue: in fact I [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":299,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","footnotes":""},"categories":[34],"tags":[24,22,29,21,30],"post_folder":[142],"class_list":["post-156","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-other-stuff","tag-crud","tag-database","tag-database-admin","tag-mysql","tag-mysql-admin"],"_links":{"self":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":0,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/media\/299"}],"wp:attachment":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/tags?post=156"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/post_folder?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}