Setting up a Windows Development Server

Recently we set up a new development environment from scratch. Here is a profile of the process we used.

The project at hand was process development/ERP for a small business based out of Vancouver, Washington, USA. The client was currently using a mish-mash of common SOHO software products, including Adobe professional products and Microsoft Office, and their process was very convoluted.

Our first step was a consultative meeting that immediately produced a lot of value and actionable insights into optimization of their business process.

We identified the key elements in their process.

Since they had a Microsoft Access database in a core role in their internal proceses, we outlined a path from Access to SQL to a web-based app (the same basic process development we have been doing professionally for over a decade).

In order to facilitate this development process, we immediately provisioned an Amazon EC2 instance with the latest and greatest Microsoft Windows Server. Going this route is much cheaper and faster than using local hardware and purchasing the required software licenses. Part of the low cost of Amazon Web Services includes the necessary licenses.

Since we do so much development work locally, on either Macs or Linux-based machines, I was curious to see what tools we would set up on this Windows based server for our team to share.

There is a saying about old dogs and new tricks, and there is certainly an analog applicable to software developers. As I was the one setting this up, I brought along many of my favorites tools — outdated or not. First of course came the truly cross-platform (or consistently developed for multi-platform) tools that remain the same across the various dev platforms.

In this case these were:

As far as Windows specific tools for this dev server, they included:

We connected SourceTree to our BitBucket account and were off and running. With the distributed source tracking, we are all able to program locally and push and pull our changes to and from the central repository.

It’s been a little while since I set up a Windows Server as a Dev environment, and I guess I was a little surprised to see myself using the same old tools. However, it gets the job done, and that’s great!

 

Sophos Home Launched

SophosHome

There is some very exciting news from Sophos — Sophos Home has launched (in beta) for free, for non-commercial use. It is licensed to never expire, and it works on Mac and Windows. This is very good news for every home computer!

Compiling the MSSQL.so extension for PHP 5.3.5 on MediaTemple DV 4

We just enabled the MSSQL extension via FreeTDS on a Media Temple DV 4 VPS. Here’s a line by line of how we did it, borrowing heavily from http://www.mavrick.id.au/2012/php-5-3-6-mssql-freetds/
, but adding the particulars for the MediaTemple DV and for the particular version of PHP (5.3.5) that we were using:

Make a directory to hold these sources:

cd /
mkdir /source
cd /source

Grab the source of FreeTDS:

wget http://mirrors.ibiblio.org/freetds/stable/freetds-stable.tgz

tar zxvf freetds-stable.tgz
cd freetds-0.91

./configure –enable-msdblib –prefix=/usr/local/freetds
make && make install

For some reason these files need to be copied over:

cp include/tds.h /usr/local/freetds/include
cp src/tds/.libs/libtds.a /usr/local/freetds/lib

cd /source

Adjust for your desired version of PHP (this example is 5.3.5):

wget http://museum.php.net/php5/php-5.3.5.tar.gz
tar xvfz php-5.3.5.tar.gz
cd php-5.3.5

cd ext/mssql
phpize
./configure –with-mssql=/usr/local/freetds
make

Now, when we first ran the make command we had to deal with a type redefinition in

nano /source/php-5.3.5/ext/mssql/php_mssql.h

Copy the extension to the proper directory… You can find out what directory it is with this command:

php -i | grep extension_dir

In our case it was /usr/lib64/php/modules.

cp modules/mssql.so /usr/lib64/php/modules

Edit php.ini file (this is the global one):

nano /etc/php.ini

Add:

extension=mssql.so

Then restart your web server:

/etc/init.d/httpd restart

and done!


Other PHP MSSQL Resources:

http://php.net/manual/en/mssql.setup.php

https://github.com/jamestkirk/devbox/wiki/install-mssql-php-extension

http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/

https://docs.moodle.org/22/en/Installing_MSSQL_for_PHP

http://howtogetitworking.com/2008/02/26/how-to-install-mssql-extension-for-php-on-unix/

http://www.linuxquestions.org/questions/linux-server-73/how-to-enable-mssql-on-linux-589956/

 

UPDATED:

(For reference:)

I compiled the pdo_dblib.so extension… but it looks like PHP is compiled with –disable-pdo. So I went back to mssql_connect as a connection method…

Logging in as the user to the bash shell, I could telnet to the database server’s ip at port 1433.

From the command line as well, I could run tsql (the diagnostic tool that comes with FreeTDS) and connect to the server, where I was able to verify that the hostname, instance, and dbname lookups are correct. I could even run T-SQL statements and query the database successfully from there.

I configured the FreeTDS conf file to have [appname] as a reference to the server, and then accessed via the following code in:

putenv("FREETDSCONF=/etc/freetds.conf");
$hostname = 'appname';
 $username = 'username';
 $password = 'password';
$databasename = 'database';
//connection to the database
 $connection = mssql_connect($hostname, $username, $password)or die("Unable to connect to $hostname");
 echo "
Connected to MSSQL
";
mssql_select_db($databasename,$connection);
$result = mssql_query("SELECT TOP 1 field from table");
$row = mssql_fetch_array($result);
echo("
Result from sample query: ".$row[0]."
");

Which outputs the expected:

Connected to MSSQL
Result from sample query: x

 

​This was the missing puzzle piece:

 putenv("FREETDSCONF=/etc/freetds.conf");

 

Apparently FreeTDS looks in /usr/local/etc by default, not /etc.

Custom Repositories for GitHub Forked Composer packages

So today we had to make a custom repository so that our composer installs could look for custom changes to a particular package that was causing a problem with one of our client’s production applications.

The only current change in this particular package was a solitary “if” statement added to a single line of code. This statement checks to make sure that the object operated on is indeed an object: in certain situations in the production app it throws a fatal exception claiming a “non-object.”

First we had to ask two (rhetorical) questions:

(1) Where do PHP Composer packages come from?

and

(2) How do you get composer to install a non-composer package?

The first step was to fork the package on GitHub:

The original package is Piotr Śliwa’s excellent:

https://github.com/psliwa/PHPPdf

And the fork lives here:

https://github.com/yourcomputergenius/PHPPdf

We looked at simply adding the forked package to Packagist, but although we intend on maintaining this as a “real long-term fork”, that is only if this change or an equivalent fix are not added to the primary package in the near to medium term. Since that seems like an edge case, we were happy to go the VCS route. Satis and Toran Proxy just looked like overkill for this simple implementation.

Once the forking was complete, we cloned the forked package into GitHub for Mac (nice!).

We branched into “missing-object-protection” (the name of the branch will be important later).

We edited the file “lib/PHPPdf/Core/ComplexAttribute/ComplexAttribute.php”, committed the change, and pushed.

Then on to editing composer.json.

We tried to run “composer require” and “composer update” on a development version of the application, after “composer remove” took care of the original psliwa/PHPPdf package. However, we ran into the issue that our newly created PHPPdf branch no longer satisfied the requirements for the PDF Bundle dependencies that was also used by the production app!

Back to GitHub we went, and we forked:

https://github.com/psliwa/PdfBundle

to:

https://github.com/yourcomputergenius/PdfBundle/

Then we cloned that into the desktop and made a solitary commit to the new fork’s master branch: a single commit updating the requirements in that project’s composer.json.

Then we updated our repositories in our development machine’s composer.json, just after the “require-dev” entry, so it contained entries for both newly forked packages:


    "repositories": {
        "yourcomputergenius/php-pdf": {
            "type": "vcs",
            "url":  "https://github.com/yourcomputergenius/PHPPdf/"
        },
        "yourcomputergenius/php-bundle": {
            "type": "vcs",
            "url": "https://github.com/yourcomputergenius/PdfBundle/"
        }
    },


We were able to leave the names the same in the “require” section of the composer.json file — one of the beautiful (and maddening) things about composer is the presence of these sorts of conventions. Composer is smart enough to figure out which packages are being replaced by custom repos.

However, we did update the “require” section of composer.json to look for the “dev-missing-object-protection” branch, as below:


        "psliwa/php-pdf": "dev-missing-object-protection"


The long and short of the day is that the application runs “composer update” and successfully grabs those two packages from the forked repos. Hooray!

Why 3rd Party Providers (i.e. Google) for OpenID/OAuth is a bad idea:

Why OAuth 3rd Party Providers are a bad ideaScreenshot 2015-01-07 09.44.01

Both @LucidChart and @SaneBox are using the old methods… and probably many more startups as well!

@LucidChart Why no version numbers insert?

Screenshot 2015-01-05 07.59.01

Screenshot 2015-01-05 07.59.31

Screenshot 2015-01-05 07.59.50

 

Updates to PHP 5.4 Cause Errors in Pagelines

 

The error is: Warning: Creating default object from empty value in /wp-content/themes/platform/includes/class.layout.php on line 167

 

And the solution (turn off displayed errors):

 

add to wp-config.php
ini_set( ‘display_errors’, 0 );

http://wordpress.org/support/topic/warning-error-creating-default-object-from-empty-value

Somewhere in here there is a way to display 500 Errors in Remote Browsers with II 7.x

http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5
http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5/2640607#2640607
http://www.ksingla.net/2009/02/iis75_updates_to_custom_errors_and_compression/

Fascinating stuff about what Job Offers tell us about corporate architecture

http://lzone.de/What-Job-Offers-Tell-About-Architectures-4

Getting Excited about Sophos new UTM Offerings

 

Sophos UTM Offerings

 

http://www.sophos.com/en-us/products/unified-threat-management/how-to-buy.aspx

Contact us if you are interested!