CodeIgniter 4 Array in Config with .env file

The .env file can use dot syntax to represent associative arrays but the documentation is poor, here is how I did it.

Create a new class in the Config directory e.g. Salesforce.php

 '',
		'account2' => ''
	];
	public $campaigns = [
		'campaign1' => '',
		'campaign2' => ''
	];
}

Add lines to the .env file

salesforce.accounts.account1 = 'config('Salesforce');';
salesforce.accounts.account2 = '00123451HKB';
salesforce.campaigns.campaign1 = '1234000000dBAEvA';
salesforce.campaigns.campaign2 = '1234000000dBAEvB';

Finally to access within your controller

$salesforce = config('Salesforce');
echo $salesforce['account1']; // displays 00123451HKB
echo $salesforce['campaign2']; // displays 1234000000dBAEvB

Advantages: You commit can commit the files in the Config folder to version control without them storing sensitive information while the sensitive data stays in the .env file and is unique to a particular environment.

SEO and image file names

Surprisingly it looks like even the filename of an image used in a website has SEO benefit – see supporting links below – this may be a pain but a multilingual site should consider duplicating images in order to use different filenames containing keywords in each of the languages a site uses.

Supporting Links:

Sublime Text – British dictionary for spelling

If you want a British English dictionary in Sublime Text 3 for spell checking, choose Preferences / Settings and add the following line:

"dictionary": "Packages/Language - English/en_GB.dic"

The Grid – Launch

I’m excited that my founder membership of The Grid has just been enabled. I’ve only spent a short time using it so far but it’s making WordPress feel ancient. The Grid uses AI to design the site according to the content and changes that design with time.

https://thegrid.ai/willis-owen

Email hosting with multiple accounts for a family

I have looked around for cost effective hosting for multiple mailboxes for example if you have your own domain name and want to give multiple family members email or if you run a small business with a few employees.

After a lot of research I recommend Tsohost (that’s an affiliate link but I’m not motivated by that – I only found out about their affiliate service after signing up for their hosting).

I looked at the services below before making my decision. Criteria were: Hosting for multiple mailboxes, webmail access, junk mail filtering, IMAP access, multi GB of storage, competitive price. Prices as at July 2016.

FastMail – based in the US, $40 per annum. I wasn’t keen on having email hosted in the US.

RunBox – based in Norway – that’s better than the US due to their privacy rules. $35 for main account but sub-accounts are an additional price and these can add up.

Fasthosts – £2 per month for 2 x 2GB mailboxes – not viable as I needed more for family

1 & 1 – £28.80 per annum with 2GB storage and 20 email accounts. This was one of the best offers and a real contender however the website didn’t mention junk mail filtering.

PlanetHippo – 10 mailboxes, 400MB size, £36 per year.

UK2 – Shared hosting with cpanel. £28.51 – doesn’t mention mailbox size or spam filtering.

Freeola EmailPro, has got antispam filters, £24 per annum, looked good but do I have to move my DNS to them and they didn’t offer any web hosting in that package.

Finally Vidahost/Tsohost. £29 annually (£31.32 including VAT) plus you get a free domain name. 2 GB storage shared between 25 mailboxes – web hosting that includes SSH access, Git, Cron, anti spam and 6 hosted websites. They were also recommended by a colleague who’d had good customer service for years.

Update January 2017 – With Vidahost you can now enable https on your website with a free SSL Certificate from Let’s Encrypt. Let’s Encrypt is available on all Cloud Hosting packages.

Update May 2018 – Vidahost has merged into Tsohost and the starter plan is now £34.80 annually.