Laravel Caching – Not seeing changes in views

We noticed a problem where minor updates to Views in Laravel 5 were not being reflected when refreshing the browser.  The only way to see the changes was to force an error in the Controller and then the View would be refreshed. Not only was this annoying, but if we forgot about this work around then much frustration is encountered.

The solution is to alter the OPCache settings in the PHP.ini:

opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

Remember to restart PHP FPM.

Why Would You Do This!?

The Penny’s Dropped

A few years ago, I kept seeing weird code in reputable projects. It didn’t make sense.

if (7 == $day) {
// do nothing
}

Any normal person would have written this:

if ($day == 7) {
// do nothing
}

They mean the same thing but the latter is more readable.

But it’s also frightening similar to:

if ($day = 7) {
// do nothing
}

But day was 3 and we’ve just set it to 7 and no one’s turned up for work.  (Yes text editors might flag up this inadvertent bug with pretty colours), but they might not.

It’s a very difficult bug to detect as it’s consequences can go unnoticed for ages.

However, doing this reveals the bug instantly:

if (7 = $day) {
// do nothing
}

This is called Defensive Programming. A good habit to get into, but expect the time saved in bug detection to be allocated to discussing why you’re writing weird code to inquisitive inexperienced colleagues.

Short Part of IF at the Top

Another scenario is having the shorter, less important part of an if(){} statement at the top:

if (false ) {
// quit
} else {
// do this
// do that
// do this
// do that
// do this
// do that
// do this
// do that
}

This ensures the shorter condition doesn’t get forgotten about. A text editor with code collapsing helps, but when using VIM or Nano it’s not always an option.

Hello from Bournemouth.

Laravel PHP Freelancers Bournemouth

Laravel PHP Freelancer Bournemouth

Whether you’re another web agency, co Laravel freelancer or end client needing Laravel skills, we would be interested in helping you with your Laravel project.

We diligently start off the day watching Laracasts before pressing on with Laravel PHP development.

We use Forge with Digital Ocean for the production server, and Homestead for the local development server(s).

14 Years PHP Developer Experience

That’s a long time we’ve been writing PHP! PHP frameworks didn’t exist then. Back in the day, we had to write everything from scratch – from CMS, shopping baskets and forums.

We learned at University that there’s no such thing as a job for life – well PHP isn’t going anywhere for another 14 years so it really is a job for life.

One consideration, PHP is ever changing, as well as all the tools, frameworks and frontend stuff that go with it.

Endless learning.

How to Chose a PHP Developer

Ensure they know Object Oriented (OO) PHP, have at least 5 years commercial experience, and are fluent in Laravel, Zend Framework 2, Phalcon or other modern MVC PHP frameworks.

They need to have worked on at least 5 big PHP projects before getting a real understanding of how to organise and manage code.  Even better, ensure the PHP freelance developer has started projects from scratch.  It’s easy to dive into an existing PHP project, with colleagues to help with questions, but a PHP programmer who has single handedly created massive projects alone, and from scratch, has invaluable experience.  Obviously they’d need to have collaborated too!

Get the balance and the skills right. For Web App Development, choose Ringwood Internet, near Bournemouth.

WordPress “Web Developers”

There are hundreds of WordPress web designers in Bournemouth who don’t know any fundamentals of web design or HTML.  They just click ‘install WordPress’ from their £30 per month Reseller hosting panel. Add a funky theme, a few plugins and job done.  A professional website …

This week, we took on a new client with WordPress site.  It had a number of plugins including an SEO plugin. Great. All set up nicely.

Pity the WordPress web designers didn’t untick the box which says “Discourage search engines from indexing this site”.

In the background this places a <meta> tag on each page telling search engines, ie, Google, not to index this page.

That means that despite all the SEO configuration, the site is not listed on Google. Did the WordPress web designers notice or even understand … ?

Always use Software Engineers to build your website.

(Your digital camera makes you professional photographer)