phpstorm-ubuntu-banner

PhpStorm on Xenial Xerus

Over the weekend I made the jump from Fedora 23 to Xenial Xerus (Ubuntu 16.04)!  Here is a quick and dirty install of PhpStorm on Xenial Xerus.

This was pretty simple, I remember past installs you had to mess around with OpenJDK to get it to install, I didn’t experience any of that here!  Specifically, I installed PhpStorm 2016.1 on Kubuntu 16.04, but it should be the same process on regular Ubuntu and more than likely any other spin-off.

Here is the procedure:

  1. Download PhpStorm from the JetBrains site – https://www.jetbrains.com/phpstorm/download/#section=linux-version or if you are really fancy use wget.
  2. Once downloaded extract the archived file either by right-clicking and choosing the options to extract or via command-line:
    tar -xvf PhpStorm-2016.1.tar.gz.
  3. Once extracted, move and rename the directory via command-line:
    mv PhpStorm-2016.1 /opt/phpstorm
  4. Run the shell executable within the bin directory:
    cd /opt/phpstorm/bin
    ./phpstorm.sh
  5. Now you should get a popup to accept JetBrains Terms.
  6. Then you will get a popup to register PhpStorm by pasting authorization code, connecting to authorization server, linking your JetBrains account or you can install with a 30 trial.
  7. Finally you will be asked if you want to import past settings or start fresh.

That’s it!  PhpStorm should open up their start page where you can either open a project or create a new one.  When you put this in the /opt/ directory, PhpStorm should have setup a launcher icon under the “Development” applications category as well.

Have fun kids!

Do you put branding on your client sites?

As a developer/designer, do you put your branding on your client’s sites?

Personally, I avoid doing things like that. I get that it is a way to advertise your company or services, but it just seems wrong and tacky to me.  I’m referring to when you go to a site and in the footer there is a link and/or text saying something like “Website designed and developed by Some Company” or worse when it is a WordPress site and they have their logo on the wp-admin page…  I assume these companies OK the text with the site owners and all, but to me this practice is sooo 1998 and is just gross.

To clarify further, I’m not talking about free/open-source products and sites that put in things like “Powered by WordPress” in the footer, I’m taking about webdev and marketing shops that throw their branding on their client’s paid for sites.

A better option you ask?  I’m down with less obtrusive practices.  So a little logo in the footer with no text, or putting your info in the comments of CSS and theme files, etc.  If you want the recognition put the site in your portfolio and call it good.  If the client is truly happy with the product you gave them they will let everyone know who did the work for them.

What do you think, is it OK to do?  Leave me a comment!

/rant

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.

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

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/.

Edit:

The code above does not work… Here is a working example of my example posting in my comment by Moya:

$query = $connection->createQueryBuilder();
$searchIds = array(‘2345′,’A567’);
$query->select(“empMain.id, empMain.first_name, empMain.last_name, empMain.email, empMain.phone”)
->from(“employeeMain”, “empMain”)
->where($query->expr()->in(“empId”, $searchIds));

$subQuery = $connection->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”);

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

$sql = $query->getSQL();

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!