Category Archives: PHP

Laravel 4.2 Set up Cron for Laravel Artisan Command

Brief instructions to setup a Cron job on Ubuntu for a Laravel PHP Artisan Command.

Create a Crontab for the vagrant user
$ sudo crontab -u vagrant -e

Add the following lines:

#test the cron every minute
*/1 * * * * /usr/bin/php /vagrant/ahvla-beta/artisan command:login-access –status=enable –disable-confirm=1 –disable-log=1

#test that the cron is running without PHP dependancy
*/1 * * * * echo “$(date)” >> /vagrant/project-root/cron-contents.txt

Save the file.

Check the contents

$  crontab -l

 

 

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.