Laravel 5.X directory permissions / ownership setup

According to the Laravel docs, “After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run”. After running this command to install Laravel via Composer:

Change directory ownership by running these commands:

Then you […]

Read More

PHP: Parse Dates in CSV with inconsistent date formats

A friend was having trouble with a CSV file that she needs to process via PHP before saving to database. The CSV files uploaded to the server have inconsistent date formats such as:

So I prepared a PHP script that lists possible date formats in an array $possible_date_formats and then iterates through the dates […]

Read More

Web Security: How SQL Injection is done

SQL injection is one of the most common website exploits. For us developers to prevent SQL injection attacks, we must first understand how it’s done. Together, let’s review the basics of SQL injection. Remember, let’s use our knowledge on good things only, okay? The scope of this post is only a MySQL injection sample from […]

Read More

Laravel 5: activate API token guard and print “Unauthorized” instead of login redirect

In Laravel 5, I wrap my API routes in a route group like this:

Notice that I use auth:api and throttle on my middleware array. auth:api turns on the auth middleware with API token as guard, while throttle activates rate limiter for APIs. To get started with API token authentication, you may read https://gistlog.co/JacobBennett/090369fbab0b31130b51. […]

Read More

Laravel update from v.5.0.35 to v.5.2.32 hiccups and solutions

I tried to update Laravel 5 today and here were the steps I had to take. First checked my Laravel version before the update:

Edited composer.json in my laravel’s root folder like such:

Run this on command line:

You might need to delete root folder’s composer.lock file before the update can actually […]

Read More