Install PHP on Windows

Install PHP on Windows

Step by step guide on how to install PHP on Windows for the purpose of PHP Development.

I’ve found myself switching computers and installing new operating systems lately. With each computer change or OS install, I must install a fresh copy of PHP. It happens every couple years so I forget all the steps… A couple months back when I found myself installing it again I made sure to make a couple notes.  Here is how to install PHP on Windows.

Please note this is just PHP, not a full server setup. I use PHP locally for development tasks and utilizing PHP-based dev tools like Composer, PHPUnit, PHPCS, etc. To run a PHP site you would also have to install a web server such as Apache and MySQL would also be handy.

Here we go:

  1. Download a non-thread safe version of PHP for windows from windows.php.net.
  2. Unzip it and put it somewhere on your computer. For example at C:/php/.
  3. Setup the .ini file by doing the following:
    1. Rename one of the .ini  files to ‘php.ini’. I generally use the development one: ‘php.ini-development’.
    2. Uncomment and change the ‘extension_dir’ to match the ‘ext’ directory of your install (e.g.: C:\php\ext)
    3. Uncomment the following Windows Extensions.  Others may need to be uncommented depending on what you are running.
      • extension=php_curl.dll
      • extension=php_file_info.dll
      • extension=php_mbstring.dll
      • extension=php_openssl.dll
  4. Setup PHP in your ‘Path’ Environment so you can run PHP globally by adding the path of your PHP install to the end of the Path variable (e.g. add ‘;C:\php’).

Now PHP is ready to go. You can test by opening a Command Prompt window and typing the PHP info commad: php -i. Once PHP is installed, I’d suggest installing a couple other things: PEAR and Composer.

You can install PEAR by downloading the ‘go-pear.phar’ file from pear.php.net/manual/en/installation.getting.php and running it in PHP: php go-pear.phar.  Follow prompts, defaults are fine.  Once the install is complete, run the registry update by double clicking the ‘PEAR_ENV.reg’ file that is generated.

To install Composer, download the PEAR file from getcomposer.org/download/.  Run it with PHP to finish the install: php composer.phar.

Good luck!  Please comment if you noticed anything I forgot to add.

Read More

FED Toolkit / Boilerplate to check out!

A friend of mine is sharing his FED (Front-End Developer) Toolkit / Boilerplate on GitHub.  It’s platform agnostic and meant to help setup client-side apps quickly. It’s also easily extendable to fit your needs.  It utilizes Node.js and npm, so make sure you have those installed.  It uses gulp and webpack to compile and minify files and also uses bower for library package management.

Check it out!  If you like it, give Anthony some love!

https://github.com/anthonyLukes/gulp-boilerplate

Read More

Joining a Subquery to Doctrine QueryBuilder

I was faced with an odd situation the other day and couldn’t find anything on the Internet to point me the right direction… I needed to join a subquery to my query using Doctrine’s QueryBuilder. I saw nothing promising on my searches and nothing in Doctrine’s docs. After some tinkering I discovered that I could slap in a query within join functions. I ended up creating the subquery as a new QueryBuilder instance and spit out the SQL into the a join function.  This should work on all their join functions: join(), innerJoin(), leftJoin(), and rightJoin(). Here’s how it works:

If you look at what the functions are doing it will click.

From the API:

join( string $fromAlias, string $join, string $alias, string $condition = null )

So when you do this: $qb->join(‘t1’, ‘tbl2’, ‘t2’, ‘t1.id = t2.id’), Doctrine is doing this behind the scenes: JOIN tbl2 t2 ON t1.id = t2.id.  So instead of adding a table as the $join variable, I dump SQL in there.

Here is a sloppy example for you:

Lets start with the base query…

$qb =$conn->createQueryBuilder();
$qb->select("emp.id, emp.first_name, emp.last_name, emp.email, emp.phone")
->from("employeeMain", "emp")
->where($query->expr()->in("empId", $searchIds));

Now our sub query…

$subQuery = dbal()->createQueryBuilder();
$subQuery->select("GROUP_CONCAT(emp.jobTitle) AS jobTitle,  emp.empId")
->from("employeeMeta",  "emp")
->where("emp.locationId = '345'")
->andWhere($query->expr()->in("empId", $searchIds))
->groupBy("emp.empId");

Put it all together now!

$query->leftJoin("empMain", "(".$subQuery->getSQL().")", "sub", "empMain.id = sub.empId")
->addSelect("sub.jobTitle");

Cheers!

For more information on the Doctrine Project, check out http://www.doctrine-project.org/.

Read More

Welcome!

Welcome to the new CaseySays.com!  My goal for this rendition is to regularly post thoughts, experiences, solutions I come up with while programming.  Hopefully I can help someone that is having similar problems that I have experienced and figured out.  Please post comments, let me know if what I came up with was helpful or just plan wrong! 😛 Welcome and enjoy!

Read More