I added some new improvements to the “Insert Script” WordPress plug-in.  You can now declare a JSON string and it will parse it out as $json_vals_arr, an array that gets passed directly to your external PHP script.

You can also declare “strings” instead of “vals” as a GET URL string like:  “strings=’variable1=value1&variable2=value2&etc=andSoOn'”.

To download the most recent version, type in “Insert Script” and select the plug-in author “Aaron Belchamber”.  To learn more, visit the official Insert Script WordPress Plug-in Page.  This is a simple and clean way for WordPress PHP developers looking to integrate external scripts and content within a WordPress page, post, or widget.


These local web development servers are fast and free to set up.  I always set them up on another computer so they’re available on  my local home network without slowing my own computer down.  Be careful setting this up on the same computer you want to use to write code, unless you have a blazing fast computer.  Even if you have an 8 core loaded with RAM, I still wouldn’t install dev sites on the machine I also use to write code, edit video and produce 3D animations it just slows you down, and besides, if you can afford a nice machine, use your old computer as a dev or buy a $500 box to avoid clogging your desktop and slowing your computer down to the point it’d be almost as slow as developing websites on your remote host — the world’s worst, most inefficient and unsafe way to develop websites.

Here’s a quick run through of my latest checklist instructions and resources to install a new local dev server (web development server) to run WordPress, Symfony, and OpenERP.  This also includes installing Webmin.  Once you find a reliable dev server that you set up, keep everything updated and you should be great to clone a server to create fresh new dev servers for multiple projects fast and easily.

It’s always a good idea to go through the steps and set up a new Virtual Machine in “Virtual Box” just in case you have to install a new flavor of Linux.  As you can see, CentOS and Ubuntu are my favorites, but you should always try and set up a Linux OS closest to the version you are running on your live host and there always seems to be a new technical challenge, especially if your company uses advanced firewalls.

Installing Ubuntu

Good overview to install Ubuntu on VirtualBox:  https://www.youtube.com/watch?v=1Nov2yDIk-4

Settings > Network:  Bridge Adapter
Run, choose file — ubuntu-14… -server-i386

System for 64 bit go to Acceleration

Setting up static:  https://www.youtube.com/watch?v=GaM9nLvyYDA

Login
sudo nano /etc/network/interface

Change in this file:  inet dhcp to “inet static”

address 192.168.0.13  <- your desired internal dev IP  ->

(Note the pattern with the masks where zeroes are below)
netmask: 255.255.255.0
network:  192.168.0.0
broadcast 192.168.0.255
gateway  192.168.0.1  <- router ->

dns-nameservers  192.168.0.1
sudo reboot

log back in

ifconfig
ping www.google.com

Install webmin on your virtual machine:

sudo nano /etc/apt/sources.list

at top of file:

#webmin
deb http://download.webmin.com/download/repository  sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Ctrl-X

wget http://www.webmin.com/jcameron-key.asc
sudo apt-key a add jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin

then go to your internal dev IP you set above:  192.168.0.13:10000

=========

Installing Virtualmin

On FRESH INSTALL CentOS:  https://www.youtube.com/watch?v=ERM-Ty0jjjQ

Log in:
sudo yum -y update
sudo yum -y install perl
sudo yum install wget

wget http://softwaer.virtualmin.com/gpl/scripts/install.sh

sudo sh install.sh

http://IP_Address:10000

Setting up multiple IP for VMs:

Network Adapter Settings — can have 4 adapters

Set 1 to
NAT – VirtualBox runs own DHCP
Port Forwarding is available, but leave

Set 2 to
Bridged

Promiscuous Mode – will decode packets not meant for machine — select “Allow All”
Leave MAC address set.

Notes:

Internal Network — available to other VMs inside
Host only:   127.0.0.1
Generic Driver:  Any OS can recognize


In normal SQL queries, you can use “WHERE IN” like this: “WHERE id IN (1,5,10)” as in:

If the list 1,5,10 “contains” the value represented by the value in the “id” field.

However, if you define a comma delimited string, you can’t simply do this:

$idListString=”1,5,10”

$dql=”SELECT d FROM Your/Entity d WHERE id IN (:idList)”

// and in your $dql query ->setParameter(”idList”=>$idListString)

This will only return the first result!   However, if $idList was an array $idListArray=array(1,5,10) then ->setParameter(“idList”=>$idListArray) works as expected.

This actually makes sense, the issue I found is that the Doctrine version of MySQL’s “WHERE… IN”  where a value is contained in a list is not well documented.  So web devs, especially Symfony developers beware!  PHP, Symfony, Magento, WordPress and MySQL experts will run into different web development issues — even as experienced experts, we’re always learning and improving.  This is just an obscure time saver, obscure probably  because it is very difficult to find search results and help related to the “MySQL IN” filter because the two-letter word “IN” is obviously omnipresent on the web in so many different contexts.  Searching “MySQL Contains IN filter” or something like that will help you find more information about the MySQL “IN” filter, function, operator — however it’s categorized.


Here’s a handy trick to define things like your Google Analytics ID and domain on a global level then be able to call on those global variables in any Twig template.  This allows you to put unique values, usernames, etc in your config files and even different values in different environments like config_dev.yml.

Here’s a quick demonstration.  In config.yml file (your production environment) twig declare your globals:

twig:
  globals:
     google_analytics_id: "UA-XXXXX-X"
     google_analytics_domain: "www.belchamber.us"

Then in your Twig, call on these globals like so:

 <p>Google Analytics ID is: {{ google_analytics_id }}</p>

Keep in mind “google_analytics_id” can be any variable name you want.  To learn more, visit Symfony’s Twig Reference page.  This was a great tip that helps keep your global values separate from your code, this decoupling and modular approach allows for quick changes and scalability later.

As you can see, injecting a list of global values into your Twig views is pretty easy and is exactly what Sensio Labs had in mind when it designed the Symfony framework — it’s supposed to help web developers develop business solutions faster because developers didn’t need to keep rebuilding the same tools to get the system to perform the tasks needed.
Aaron Belchamber
http://www.belchamber.us
http://www.aaronbelchamber.com