Using Webpack in Codeigniter 3 – Part 1 Set-Up

Webpack is a brilliant tool for bundling all your assets and their dependencies into one single file to distribute with your website. Out of the box Codigniter doesn’t include any kind of modern front-end tooling so we will have to import webpack and set it up from scratch. This will most likely be a multi part series to cover this topic.

We can compile our Javascript modules, build any SASS/LESS files and even minify everything, so lets get started.

Continue reading Using Webpack in Codeigniter 3 – Part 1 Set-Up

Using the Laravel Blade templating engine in Codeigniter 3

As anyone who reads this blog or knows me personally, my love for Laravel is deep. That’s great for greenfield projects but a lot of code I deal with on a daily basis is mostly written in Codeigniter. One thing I really miss in CI (among many other things) is a template system. In this tutorial I will show you how to include the Laravel Blade template system in your Codeigniter project.

Continue reading Using the Laravel Blade templating engine in Codeigniter 3

Laravel Eloquent – Integrity constraint violation: 1452 foreign key constraint or General error: 1005

Are you trying to set-up a foreign key constraint on one of your tables and you’re getting a 1452 error?

[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

 

You might also get a General error: 1005

[PDOException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `app`.`#sql-33d4_1a2` (errno: 150 "Foreign key constraint is incorrectly formed")

 

This is a MySql issue and not a Laravel one.

Continue reading Laravel Eloquent – Integrity constraint violation: 1452 foreign key constraint or General error: 1005

Build a PHP login system using Laravel 5

Laravel makes it super easy to build a login system because it has everything already built and configured for you, here is how to create a login system using Laravel 5.2

Lets create a new Laravel project using composer:

 composer create-project --prefer-dist laravel/laravel login 

To get the authentication up and running we need to do a few things but luckily Laravel makes the set-up a breeze.

Continue reading Build a PHP login system using Laravel 5

How can I prevent SQL-injection in PHP?

I constantly see this question asked and the answer is so simple yet people ignore or outright refuse to use it. The answer is prepared statements with the PDO extension. There is simply no need or a solid valid argument to use mysqli or even worse mysql, mysql_* where deprecated in PHP 5.5.0 and removed completely in PHP 7.0.* so stop using it!

Continue reading How can I prevent SQL-injection in PHP?

Data breaches and the level of password security

I recently wrote a post about how to correctly hash passwords using PHP. As this story was shared on reddit it was met with the normal trolling almost every post gets on the platform. One of the issues was why did I mention such things as MD5 and SHA when the post was about correct way of password hashing. My response to this was because most tutorials (usually aimed at beginners) recommend hashing passwords with functions such as MD5 and SHA1 and I dedicated a paragraph of the article to explaining why these where bad points and why not to use them.

Continue reading Data breaches and the level of password security

How to correctly hash passwords in PHP

PHP password hashing and the new password_hash() function

Password hashing is a hot topic with many database breaches resulting in users passwords being revealed due to bad encryption techniques or even worse none at all! Never store a password in plain text, you’re not doing that anyway right?

Continue reading How to correctly hash passwords in PHP

PHP Rapid-Fire: What is the @ symbol used for in PHP?

The @ symbol is used in PHP to suppress error warnings in your code. Prepending an ampersand to a line of PHP will suppress the error from reporting but it doe’s come with a few caveats listed below.

Example: To stop errors from showing for a class

 $var = @new some_class(); 

Continue reading PHP Rapid-Fire: What is the @ symbol used for in PHP?