How to get the final url after redirects

Sometimes, you have a link. And you want to save the actual, final url that link points to. A great example of this is trying to archive something on twitter. You’ll want to store final urls for ones that are tweeted, not their url shortened one.

Anyway, I wrote this really quick in PHP and it works!

$d['initial_url'] = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $d['initial_url']);
curl_setopt($ch, CURLOPT_URL, $d['initial_url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$d['final_url'] = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

This outputs:

    [initial_url] =>
    [final_url] =>

Laravel; having a conditional choose your @extends template

I am firmly entrenched in the Laravel camp now. One thing I love about Laravel is their blade templating language. However, there is some quirkiness that isn’t immediately obvious.

Let’s say you have a template that is extending another template. You want a conditional to determine which template you want to extend. (The use case here for me is a messaging system. Logic + layout is the same on back-end and front-end, but they extend different templates).

I was trying to get this to work:



<h1>Here are things!</h1>


All it was doing was outputting the one @extends(‘base.base’) line. After much hunting, I found this great answer on StackOverflow. So, @extends() must be on the first line of a blade template, which is a little weird, but whatever. Used ternary operator like this and it works!

@extends($var ? 'account.base' : 'base.base')

Just finished the todo list for the next four days, after which we launch a new project that is running on Station, the new CMS package for Laravel we developed. It’s going to be intense, and worth it!

Announcing Lemon-filling!

This is kind of a follow up to my last post. I’ve realized the UI localization schema I came up with is pretty nice. It will need some sort of UI to add the terms, pages, etc. I’m building that out first. I’m calling it ‘Lemon-filling’. On Github.

I’m hoping to have it done before our little girl arrives, because after that I will be in babyland for a while. The best land!