I thought I was going mad for a while, but it turns out that sometimes spotting php error messages which come back from the server to the Google Chrome browser can be really tough.
If the error is inside an html element or attribute of an html element you’re going to struggle to see it in Google Chrome…
<a href="<?= $Model->fakeFunction(); ?>">link</a>
If $Model doesn’t have a method called fakeFunction then php will spit a “Fatal error: Call to a member function” error. The page that is displayed in Chrome won’t show you the error and viewing the source will also hide it from you.
Even the elements tab in Chrome Developer Tools won’t show it.
There only way I’ve been able to find the error content is to look at the network tab in Chrome and view the raw response of the document back from the server.
A few hours lost on this one!
Update: This actually doesn’t work as I’d hoped. Because flickr reports an error each time, eventually IFTTT disables the recipe after a few hours of calls. Back to the drawing board.
I’ve been trying to get IFTTT (if this then that) to send a call to a php script file when a trigger goes off for months. The problem wasn’t getting it to work in the first place, but for it not to leave any artifacts hanging around, or repercussions as I call them. I wanted the script to be triggered and that to be the end of it, with no files being created or errors being recorded.
An example of the problem would be the IFTTT Google Docs channel. You can upload a file to google docs from a url. You can define that url to be your php script and then tell your script to return a 404 (after it’s done its coding goodness) but when you view Google Docs a new file has still been created. If you want to use this for a large number of pings, you’re going to end up with a folder full of pointless files and a waste of your disc space. The Evernote and WordPress channels are a similar story. Even when you attempt to fail the call to your url (with a 404 or 503) they still create a note or post.
Continue Reading… »
Sometimes you might want to do various checks of the url in yii config main and then send every other request to a particular controller.
The rule you need to add last to the urlManager is…
'(.*)' => 'controller/action',
… and now any rule that isn’t matched previously will end up being sent to your defined controller and action.
When you develop a website for a client you should usually be considering three or even four (if you also include staging) environments where one code base may be used. Local, development and live.
In this case you may want the code to behave slightly differently depending on where it’s being used.
A good example I regularly come across is when and where to send any emails that a system generates. When you are testing locally or on a development server you certainly don’t want to send out emails to people who have no knowledge of the system.
Continue Reading… »
Two hours of my life were wasted on this one, even though I’ve done it before. So…
If you want to move your ~/Sites folder into say Dropbox or AeroFS or Google Drive or SkyDrive and then you still want to point to it from its default location don’t use an alias.
I know an alias is only a ctrl-click away, but it means all sorts of pain.
Instead, move the folder to dropbox by dragging it (yes you can do this), then open Terminal and type:
ln -s ~/Dropbox/Sites ~/Sites
Replace Dropbox with whatever the folder of your service is called.
Restart Apache either by restarting Web Sharing in System Preference -> Sharing or by using Terminal and typing:
Cross your fingers and open a virtual host in your web browser. I fought with an Alias and all sorts of folder settings and httpd.conf lines to try and get it working, and then all I needed was to use a SymLink in its place.
Don’t worry about no longer having a ‘real’ ~/Sites folder. You don’t actually need one.
Cheers to James Galley, my desk neighbour for helping my brain to click on this one.