Educating the world

Our blog has over 10,000 readers a month

Debugging PHP in Eclipse

October 21st, 2014

Debugging PHP in Eclipse requires 2 parts. Firstly change the php.ini to include the xdebug sections. All the relevant information can be found in the article Setting up XDebug under XAMPP. Second create an Eclipse run configuration to connect to the remote server which is what this article is for!

You don't have to do this next step but it makes administering your project code easier because you're not forcing all your code to live under the Apache document root. I have different workspaces for different clients so I add an Apache alias to join all the projects together under the same document root. Basically all my code lives in my client folders (along with their accounts etc) and the document root just has virtual directory pointers to those locations.

  1. From the XAMPP Control Panel, click Apache Config httpd.conf
  2. Add the following lines after the last <Directory> section. This tells Apache about the folder you would like to include.

    <directory "D:/BigSoftLimited/Clients/Oscorp/workspace/goblin/src/web/">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
    </directory>

  3. In the alias_module section add the following line to slot the afore mention directory under the document root:

    Alias /goblin "D:/BigSoftLimited/Clients/Oscorp/workspace/goblin/src/web"

  4. The restart Apache.

I'm using Yii for this PHP project but the options should be the same.

  1. Ensure you have PDT (Eclipse for PHP developers) installed.
  2. From the menu select: Run->Debug Configurations...
  3. Highlight the PHP Web Page icon on the left and click the New launch configuration button above.
  4. Give it a sensible name: Yii Goblin.
  5. In the Server tab change the Server Debugger to XDebug.
  6. In the File section Browse and navigate down to the index.php file that starts the application. In my case /goblin/src/web/index.php where web corresponds to the /goblin/ on my web server.
  7. Uncheck Break at First Line.
  8. If like me you are developing all your projects under the same document root then you will have to uncheck URL -> Auto Generate and enter the entry path to the applications. My Yii project is located at /goblin/index.php. You could set it up as /goblin/index.php?r=controller/action but you will find that you are constantly changing the configuration to test new controllers.
  9. You can leave the rest of the options as is and click Apply followed by Close.

To run

Yii commands I keep forgetting

October 15th, 2014

Been using Yii for a while now and there are several functions that I need to use from time to time that don't seem to want to stay in my brain. Most of them seem kind of obvious now that they are in front of me which is why this is so annoying!
It's usually quite difficult to Google them because they are related to doing ordinary Yii type things and so I can't make the search specific enough to narrow it down.

Creating a URL without the wrapping anchor tag
This is handy when you need to generate a URL in order to place inside some Javascript.

PHP

echo Yii::app()->createUrl("recording/scheduler_data");

Creating Javascript names using compatible with Yii models

PHP

echo Chtml::activeId($model'model_field_name');

Produces: RepeatRecordForm_repeat_from

PHP

echo Chtml::activeName($model'model_field_name');

Produces: RepeatRecordForm[repeat_from]

More to come but I haven't got time to dig them out at the moment.

Historical Pubs in London UK

September 24th, 2014

I have taken all the historical pubs listed in The CAMRA Regional Inventory for London - Pub Interiors of Special Historic Interest and plotted them on Google Maps.

If you are planning a pub crawl around London and would like a selection of pubs with really nice olde worlde interiors then this is the map for you.

https://www.google.com/maps/d/viewer?mid=zcySN6tvniyk.kAcYY6Ul2aWg

If you think I've missed any pubs them leave a comment and I'll update the map.

How to pay Corporation Tax online

September 18th, 2014

Got a letter through the post from HMRC to say that my Corporation Tax direct debit had expired after a year and as a result my latest Corporation Tax payment had failed. HMRC had been plugging "pay by direct debit" for a while and last year I went to all the trouble of setting it up in order to pay it. Corporation Tax is an annual tax against the profits of your company so imagine my surprise when HMRC said they cancelled the direct debit after a year!

I phoned up HMRC and tried to ask them why they would cancel a direct debit on an annual payment after one year. They kept saying that the Corporation Tax value was different each year so I couldn't reuse an old direct debit again. I told then that my VAT payment was different each quarter and yet that still worked. This vexed them so they took my details and said someone would get back to me.

Due to the payment rejection (and being away) my deadline was upon me and I had to pay it today. Went to HMRC's website and started reading their documentation which takes you around and round in circles.

My confusion was caused by assuming that the Corporation Tax direct debit payments would be handled in the same way as VAT payments which are quarterly. Essentially, I work out what my VAT liability is each quarter then go to the HMRC web site and enter the values into the 8 magic boxes, and the site calculates what my total payment should be. Sometime later HMRC direct debits that amount from my account. Paying VAT is akin to paying my mobile phone bill each month.

I was reading the payment documentation with the assumption that paying Corporation Tax would be the same but it is subtly different.

When you enter the VAT details into the 8 magic boxes HMRC automatically creates a new direct debit instruction with the bank details you have assigned to paying VAT along with the payment amount it has calculated. This instruction is added to the system (on your behalf) and the money is debited from your account in due course.

Corporation Tax is handled differently because our accounts department has to fill in loads of forms which the finance director has to sign off as valid. Those forms maybe submitted online but the paperwork (with the signatures) still has to be posted. HMRC then creates a liability in the Corporation Tax section of the HMRC website. It is then up to me to create a new direct debit instruction with the amount we've declared and submit this to the system.

Each one of these direct debit instructions (VAT and Corporation Tax) can only be used once and then it expires from the system. My confusion had been cause by not realising that HMRC was automatically creating a new instruction for each VAT payment, and not doing that for Corporation Tax.

Now that we understand how it works it's still a bit of an arduous task to set it up. So here are some instructions to help:

  1. Goto https://online.hmrc.gov.uk/home and login.
  2. Click Services you can use from the left hand menu titled Main menu.
  3. Find the Corporation Tax (CT) section and click the Access Service.
  4. In the View account section the amount to pay will be shown as a link, click that.
  5. From the table click the date link you want to pay. This will take you to the Accounting period overview page.
  6. Find the line:

    When making a payment for this accounting period please quote the payment reference number 1234567890A00112A

    Cut and paste the long reference number and the amount to pay into a text file so you can use it later.
  7. Click the Your HMRC services in the top left corner of the screen above all the links for your Corporation Tax.
  8. Click Direct Debit payment from the Main menu navigation menu on the left.
  9. The table is a list of Direct Debit payment profiles. Click the Direct debit reference link of the bank profile you wish to use.
  10. Click Add payment plan.
  11. Select Corporation tax (CT) and click the Next button.
  12. Enter the 1234567890A00112A you recorded earlier, the amount and today's date (or The earliest date you can enter which is listed) then click Next.
  13. Check the details and click Next.
  14. There is now a useless Security check which asks you to enter your login credentials again, but if you have told your web browser to remember that information to help you (initially) login then your browser will just fill them in again for you. So click Submit.
  15. Make a note of the Direct Debit reference so you have something to give them, if there is a problem.

I'm not sure why paying Corporation Tax isn't as simple as paying VAT, but hopefully HMRC are working on it.

The rules I live by

August 25th, 2014

Peter Tatchell guiding motto is:

Don’t accept the world as it is, dream of what the world could be, and then help make it happen.

Featured on BBC Radio 4 Midweek on 25 January 2012.

Maybe it’s because I had Peter’s quote in my mind that I spotted this quote from Eleanor Roosevelt:

When you have decided what you believe, what you feel must be done, have the courage to stand alone and be counted.