Open a php project in PHPStorm using Alfred

I have been using PHPStorm for a while now and after the recent release of version 5 (seems to be much faster) I am sticking with it for the foreseeable future.

I have also been using Alfred for a long time too. I purchased the Powerpack to get access to some of the more advanced features and have never regretted the small expense.

Today I found out Syd Lawrence has built an awesome plugin called Alfred Dev Doctor which helps developers find the correct documentation whilst coding. It needed Alfred v2 and the Powerpack.

I did not know there was a version 2 avaliable so I immediently downloaded the new version. Unfortuntly I then found out that my licence key for the version 1 Powerpack did not work with version 2 so I had to upgrade my Powerpack licence. The upgrade was a small fee of £10, worth it in my eyes. Since 14 May 2012, I have used Alfredapp 6,591 times, which is an average 20.9 times per day.

Since I had the all new singing and dancing version of Alfred and the Powerpack I began looking at other things I could get him to help me with. For months I have been trying to get Alfred v1 to open a folder with PHPStorm. I was never able to get this working. Luckily in Alfred v2 this was easy.

I have created a Workflow in Alfred which allows me to hit ‘alt+space’ then type ‘phps’ and then type a folder name to find it. Once it has found it I simply hit enter and it will open that folder up in PHPStorm. Yay!

A video of this working can be found here: Video showing Alfred opening a folder in PHPStorm

You can download the Workflow here, unzip and double click to install: PHPStorm Alfred Workflow

UK Postcode database with lat & long

As we all know the full postcode database with all latitude and longitude information is Copyright to Royal Mail. This is annoying. I know there are loads of databases out there which claim to be the full dataset and there are loads of API’s which will geocode UK postcodes etc. In the past we have used an awesome service called PostcodeAnywhere which does a great job of address lookup and validation… but it’s a paid service… obviously they have to make money somehow! I have also played with Google API etc. I also think that someone released a dataset on Wikileaks but if I remember rightly this was partial postcodes (only contains the first part of the postcode e.g. TS19).

I was chatting to Alex Akass on skype the other day and he pointed me to the Ordnance Survey website who have just released a full set of UK postcodes in a database as recent as February 2012! The service, called Code-Point Open (ordnancesurvey.co.uk) contains 2,993,351 rows. This data also looks to be available on the new data.gov.org beta site under the same name Code-Point Open (data.gov.uk).

The data comes in CSV files to split the data up. I created a quick PHP script that looped through these files and put all the postcodes into one database table. All looks good.

This got me thinking. The database comes with ‘Postcode’, ‘Eastings’ & ‘Northings’ columns. There must be something you can run Eastings and Northings through to get the latitude and longitude. I did a quick Google and found a post by a guy called samjudson on this forum.

I searched for my postcode in the database and then ran the Northings and Eastings through this function to get the latitude and longitude. I used itouchmap.com to load this data on the map and compared it with the pointer that got shown on the map when I inputted my postcodes directly. They were very close, close enough to be useful I think.

So what I was thinking, was I could add the conversion function to my php script and whilst I am looping through the csv files I could also add the latitude and longitude and I will end up with a current table with full UK postcode, Eastings, Northings, Latitude & Longitude.

Would welcome thoughts…

Printing an array, string or anything else…

This post is carrying on the theme of sharing little bits of code (like my good friend @boxedfish did the other day) – How to easily split a sequence of number into a hython seperate string

This is not the greatest bit of code I have ever written and its not going to knock you over with complexity but what it will do is save your little fingers and over a year give you back quite a large chunk of time.
[php]

function output($my_array, $my_die = 0)
{
echo ‘<hr />’;
echo ‘<pre>’;
print_r($my_array);
echo ‘</pre>’;
echo ‘<hr />’;

if ($my_die == 1) { die(); }
}

[/php]

Then all you have to do is

[php]
output($my_string);
output($my_array);
[/php]

Phil Sturgeon to talk FuelPHP at next PHPNE

I can not wait until Tuesday 18th October! It has just been announced that Phil Sturgeon will be giving an introduction to FuelPHP. Most of you will know that Phil is part of the development team of FuelPHP and has already given us Codeigniter, an amazing php framework which has changed my life in many ways.

I have been involved with web development for around 10 years now. Sounds surprising but it’s true. My life/job has involved many things as well as pure web development. I have been involved with core business projects such as setting up a business, accounting and marketing as well as project and client management. When it comes to web development, my day to day activities include working with HTML, XHTML, CSS, PHP, Photoshop, WordPress, Magento, MySQL along with server setup and management. I call myself a php web developer because that is what I do most and what I love most; however I am really  a jack of all trades.

For most of the projects I have worked on I have been either the sole developer or the senior developer. Everything that I know about PHP has been self taught, everything has been trial and error. I did go to Teesside University and studied Information Technology which touched on some web development; however in my opinion the University need to seriously sort itself out when it comes to our industry, its shocking… but thats a blog/rant for another day.

Throughout my life as a developer, I been involved with many different sized project and when you don’t have another developer to bounce ideas off you learn quickly. It is also very easy for you to slip into bad habits. When you are planning a project you have to assume that your doing things the best way. You don’t want to show a ‘weakness’ and ask other developers if you are doing something the right way! After sometime, I realized I was reusing my own code over and over again in new projects. Therefore,  I started to comprise a folder of all the functions, classes, html templates and css that I would usually have to write from scratch for each project. At the time I did not realise this was known in the industry as a ‘framework’. By the time I came across frameworks such as Codeigniter, Zend and Kohana, I was too involved in my own framework. I had also made contact with other PHP developers online who were dead against using frameworks… ‘frameworks go against what PHP is’… ‘frameworks will slow down your system’… ‘frameworks contain loads of pointless code’… ‘frameworks will slow your development down’… the list goes on and on… so I got a bit stuck! I knew my own framework inside out, it was quick, it worked… why use anything else? PHP is all about using core PHP… thats what its all about… right?

One sunny day a guy called Alex Akass encouraged me to start to use an open source frmaework. I should mention that I have never met Alex in person; however we speak nearly every day on Skype. I may be a sole developer but I do have a solid development team made up of contacts I have met online and more recently at such events as PHPNE. Alex introduced me to Codeigniter and I started to use it for a live project. I work in an agency where project turnover is high. I don’t have the luxury of time to look at new technology and work on something inhouse to test it before working on a live client project. I trusted Alex and I dived in. Since that day my life has changed in so many ways. To list a few:

  • More structured framework
  • Input from years and years of other developers experience
  • Access to functions and classes I would never have thought of
  • Much more reliable and stable final projects
  • Faster project development…. much faster!
  • A shed load of online blog and video tutorials
  • The feeling I am up-to-date
  • etc…

I could go on and on… however there is one thing that is missing from the list above which has rocked my world. When I started to use Codeigniter I started to see that things were not so different to the structure I had put in place for my own framework. Things I had created functions for were included in Codeigniter. It was an amazing feeling. The years I have been working on my own learning from trial and error were not wasted. I did know what I was doing! I feel as if I owe this feeling of validation to Alex and the creators of Codeigniter. Since making the jump to Codeigniter,  every day I have had on development has been even more enjoyable than before. If there is anyone out there waiting to make the jump, stop waiting… jump! You are not alone.

Recently I have been attending PHPNE events in Newcastle. I spend an hour traveling there and back on the train so that I can join the others in the pub after the talk to network. Its been a real eye opener for me. I really enjoy meeting and talking to other developers. Today I am extremely excited because I have just put a blog post live on the PHPNE website announcing our October event… Phil Sturgeon will be giving an introduction on FuelPHP, a new ‘kick ass’ (the words he used when I was talking to him on Friday night at the #NENT event) framework he is part of.

Why am I so excited? Two reason. Firstly, Phil is a leading developer on Codeigniter. Codeigniter changed my life. Secondly I have recently been getting a lot of ear ache from Chris Scott telling me that I should take a look at Ruby on Rails, talking to me about things like migrations, ORM and HAML… Phil is also a leading developer on FuelPHP… and guess what… Fuel introduces things like ORM and migrations and has support for things like HAML…

If you are interested in attending the event you will need to be quick because spaces are limited. Head to the PHPNE website for more information and register on EventBrite asap.