How to get Git SHA in an Elastic Beanstalk App (and set other dynamic env vars at deployment)

Posted by Matt Bryson on 18-May-2015 08:57:28

As part of our deployment process, we include the short git SHA as a build number against our SemVer version number.

We wanted this available in our application UI to help identify running versions. Easy I thought, Beanstalk sets this as the Version Label when deploying, so we should be able to access that from the environment vars in PHP.

Unfortunately not, this is one of the many EB values you cant easily get to. After a lot of failed attempts, here is how we managed it as a one-liner in the .ebextensions

Read More

Topics: PHP, EC2, AWS, Deployment, EB (Elastic Beanstalk), Apache

CodeIgniter : Using variables in language files

Posted by Matt Bryson on 12-Nov-2012 12:14:57

Codeigniter uses a fairly standard way of inserting values into strings within its language files.

You define your string with placeholders, and then use sprintf to format the string.

//In your language file... $lang['welcome_username'] = 'Welcome %s.'; //then in your view or controller..
echo ( sprintf( lang("welcome_username"), "Bob") ); //Results in "Welcome Bob."

However, for values that only really change per environment / deployment, it would be beneficial to be able to refer to them from within the language file, rather than having to format the string every time you want to use it.

Read More

Topics: PHP, CodeIgniter