Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Quick Tip: Convenience Hacks for Passing Data to Views
Aug 16, 2016 @ 11:09:38

On the SitePoint PHP Blog Reza Lavaryan has shared a "quick tip" about making it easier to pass data out to the views in your MVC application. It relates more specifically to when you have a lot of values to pass out rather than just a few bits of data.

In MVC based architectures, working with template engines is an inevitable part of the development routine. It usually goes like this: we prepare and pass the data to the view. In the view, we print them based on our layout design.

[...] There are times, however, when the number of variables might be much higher than this: ten or more. In that case, we’ll have a tall list of variables (as an associative array), being passed to the respective template. It gets messy and unreadable quickly. If only there was a way to just list what we need by name, and have PHP take care of the rest for us. Well… there is!

The example shows how to use the compact function built into PHP to grab values from the current scope and return them as an array. Unfortunately it does loose the array keys with this method, so they propose an alternative with the get_defined_vars function and some simple key handling to return a more correct version of the array.

tagged: quicktip hack data view compact getdefinedvars tutorial

Link: https://www.sitepoint.com/quick-tip-convenience-hacks-for-passing-data-to-views/

Quick Tip: Deploy PHP to Heroku in Seconds
Oct 30, 2012 @ 09:50:41

For anyone that's wanted to try out the Heroku hosting platform but just want a bare-bones guide to getting up and running, NetTuts.com has what you're looking for.

We’ve raved about the brilliance of Heroku before, mostly around the fact that it makes launching a Rails or Node app rather simple without having to configure your own server. But what if you want the same kind of freedom and speed of deployment with PHP? Fortunately, Heroku has quietly offered support for PHP for quite some time.

You'll need to get their CLI deployment tool and set up an account but the rest is pretty easy. The steps to set up the git repo, add a new "heroku" branch and push the checked in code directly out to the server.

tagged: quicktip deploy heroku beginner tutorial


Content with Style:
Viewing BLOB content in phpMyAdmin
Nov 20, 2009 @ 08:57:08

New from the Content with Style blog today there's a quick tip from Matthias Willerich for phpMyAdmin users who are having issues viewing the content of blob data types.

n my phpMyAdmin installation, version 3.1.1, none of the old style config settings [...] had any effect, and the solution was terribly elusive. "view blob", "show blob", "display blob", all that Google suggested were people asking the same question, at various ages of the internet.

Finally, after wading through negative comments of forums and not getting much help at all, Matthias dug into the source and found a session variable that can be set to true and the content magically appears.

tagged: phpmyadmin blob content quicktip