Laravel Cookies

Laravel Cookies

Using Cookies in Laravel is super easy. Take a look at how we can use cookies in Laravel below:

1. To Set a cookie you can use the following code:

$ref = 'my cookie value';
return redirect('/')->withCookie('ref', $ref);

2. Then to get a cookie value you can do the following:

$cookie = $request->cookie('ref');

And it’s as easy as that. To learn more about laravel cookies you can visit the official documentation.

Additionally you can learn more about Laravel cookies by checking out this video by DevDojo:

Learn how to use laravel cookies

Video Membership Site

How to create a Video Membership Site

Let’s say you wanted to create your own Video Membership site. What would you use for that? Your first instinct might be to go with WordPress and this is definitely a viable solution; however, there are going to be a lot of disconnects and a lot of functionality that doesn’t work just right. Checkout this article about WordPress vs HelloVideo.

Now, thanks to HelloVideo you can easily create your own Video Membership website. The script is very easy to install and very easy to configure. With HelloVideo you have a powerful admin dashboard where you can add/edit/delete videos, posts, pages, and users. You can view statistics about your video site right when you login to your admin dashboard.


HelloVideo comes with 3 great themes. Each theme has separate settings that you can modify. You can also add your own custom CSS or Javascript. This app was built to seamlessly integrate with stripe and it was built the latest version of Laravel, Laravel5.

Once you gain access to the download section you will also have access to all the documentation a ton of quick start videos, and all your downloads. You will get free updates and free upgrades for a whole year.

So, if you’re in need of creating an awesome Video Membership Website, do your users a favor and get one of the best Video CMS’s available today.

Check it out at


Laravel 4.3 – What’s New

There has been a lot of buzz lately about the latest release of Laravel 4.3. Many new features will be introduced in this new version, and it is all being covered over at Laracasts. This is showing to be a larger release than was previously anticipated.


Here are a few of the key features that will be introduced in this latest version:

  • New directory structure
  • Method Injection
  • New and improved validation
  • New File Generators
  • Flysystem
  • Socialite
  • Illuminate Contracts
  • Route Caching

Now, I’m not too sure how I feel about the new file structure, already covered in one of Laracasts latest videos: I’m sure there’s good reasoning behind it; however, at first glance I’m not too thrilled about this.

There seem to be many other cool features popping up, so since Taylor Otwell has proven good in the past I’ll trust him on the change to the file structure and to all the new features. “Taylor”, thanks for continuing your awesome development on one of the greatest frameworks available.

If you want to catch all the latest features in the latest release be sure to head over to Laracasts, where Jeffrey Way will be teaching us all what we can expect from this next exciting release.


Ninja Media Script

Well, it’s been awhile since I’ve written a post. I hope to get back into my daily post routine :) In the meantime I’ve been fairly busy creating some new scripts and learning some new technologies. One of the latest scripts that I’ve written was a Viral Media Script that’s available on CodeCanyon. Feel free to check it out here.

The response has been great so far, I am reaching nearly 250 sales within the first couple months. It’s great to be able to continue to work on something that people care about. Whenever I’m working on updates during the weekend it’s a great feeling to know that I have users who are looking forward to these updates.

The script was built using Laravel 4 framework, Bootstrap 3, FontAwesome4, and jQuery.

Here are some of the screenshots of the script below:

ninja-media-script-screenshot-1 ninja-media-script-screenshot-2 ninja-media-script-screenshot-3

Be sure to check it out on the Envato page here:

And I look forward to hearing your feedback :)

How to add a new column to the database using migrations

Using migrations in laravel 4 allows users to keep a version control of their database. If you aren’t familiar with migrations I’ll give you a quick rundown. A migration is a file that creates, updates, or removes tables and columns in your applications database. So, in order to add a new table using laravel 4 and migrations you can simple use the terminal and execute the following command line:

  php artisan migrate:make add_details_column_to_course_table

This will simply create a new file inside of your /app/database/migrations/ folder. Once you open that file you’ll see an ‘up’ method and a ‘down’ method. You can then simply change your up method to the following:

public function up()
	Schema::table('courses', function($table)

Then you can change your down method to look similar to this:

public function down()
	Schema::table('courses', function($table)

Then in your terminal command line you will simply run ‘php artisan migrate’, and your new column will be added to your database. Your table ‘courses’ will now have a new column named ‘description’ and your app can always be rolled back to before you added that new column.

I hope this can help someone else out. I am basically writing this post for personal documentation sake, but if it helps out someone else then that just makes the reason for writing this post that much better :)

Renaming Database Tables in Laravel 4

Lets say you’ve been digging Laravel Migrations and you run into an instance where you need to rename your table. Would you manually change the migrations you already created to reflect the new table name, rollback all your environments and then migrate them again? Absolutely not, that is the whole reason for using migrations. Let’s say that I created a table called ‘page_info’ and I wanted to rename it to ‘page_details’. I already have a migration for ‘create_page_info_table’ so now I just need to create a new migration called ‘rename_page_info_table’, here’s how you would do it. Open up terminal and execute the following command:

php artisan migrate:make rename_page_info_table

Then inside your newly created php file (usually located in /app/database/migration), you would modify the file to look like the following:

class RenamePageInfoTable extends Migration {
	 * Run the migrations.
	 * @return void
	public function up()
		Schema::rename('page_info', 'page_details');
	 * Reverse the migrations.
	 * @return void
	public function down()
		Schema::rename('page_details', 'page_info');

And just like that you’ve renamed your database table without having to manually go through all your environments and databases to change the name of your table.

Gotta love migrations ;)

MyAuth – Laravel Authentication Bundle

So, when searching through all the Laravel authentication bundles I found some pretty cool stuff and I learned a lot about the built-in Laravel authentication system; however, I just wanted a simple authentication bundle that would get me up and running with a simple email and password login/signup.

So, I went ahead and created my own Laravel Bundle called ‘MyAuth’. It’s an authentication bundle that has a user login, logout, signup, and dashboard page. You can learn more about the bundle on the GitHub page:

Below, is a short video that demonstrates how to install, use, and configure the bundle. I hope others will find this bundle useful and easy to modify.

Hello Bundle – Creating Bundles with Laravel

Laravel is a great PHP framework for rapidly building web applications. One of the advantages of using Laravel is the ability to create re-usable pieces of code. Yes, you could always use libraries and third-party classes; however, Laravel has introduced a new way of building plug’n play pieces of functionality into your application which are called Bundles. In this video tutorial I will walk you through creating your first simple Laravel Bundle. It’s basically a ‘Hello World’ tutorial for bundles, but it’s called ‘Hello Bundle’. Anyway, Check out the video below:


PHP the difference between single and double quotes

I’ve been programming in PHP for nearly 10 years, and I would consider myself to be fairly competent with the language. It’s funny that some of the simplest things that I would program in PHP I would just accept certain aspects instead of looking further into them. I am talking in particular about single and double quotes. You can use either of these to output lines of code to a browser. You can even use them interchangeably from line to line.

What’s the difference between the two? Well, after going through a beginner PHP course I found out that using double quotes PHP will actually output and render PHP variables; whereas, a single quote will only print out the string without rendering PHP.

As an example, the following PHP code:

    $name = 'World';
    echo "Hello $name";

Will print out:

Hello World

Whereas the following code:

    $name = 'World';
    echo 'Hello $name';

Will print out:

Hello $name

It’s funny that it took me that long to figure that out. I guess it was just one of those things I didn’t pay attention to. Well, now I know :P

How to get Memory and CPU usage in PHP

So, a couple weeks ago I experienced heavy server overloads on an app due to so many concurrent users. There may have also been some code clean up that was necessary. Either way it was kind of a headache, but also a learning experience. So upon searching the interent I could not find an easy way to print out the Server Memory Usage or CPU Usage as a percentage. So, with the help of some string manipulation and a fellow co-worker we created these 2 php functions. These configurations worked on a MediaTemple (ve) server with Ubuntu 11.04.

The first function will return the Server Memory Usage:

function get_server_memory_usage(){
	$free = shell_exec('free');
	$free = (string)trim($free);
	$free_arr = explode("\n", $free);
	$mem = explode(" ", $free_arr[1]);
	$mem = array_filter($mem);
	$mem = array_merge($mem);
	$memory_usage = $mem[2]/$mem[1]*100;
	return $memory_usage;

This function will return the Server CPU Usage:

function get_server_cpu_usage(){
	$load = sys_getloadavg();
	return $load[0];

So, if you were to call the two functions in a php file like this:

<p><span class="description">Server Memory Usage:</span> <span class="result"><?= get_server_memory_usage() ?>%</span></p>
<p><span class="description">Server CPU Usage: </span> <span class="result"><?= get_server_cpu_usage() ?>%</span></p>

You’ll probably end up with a page that looks similar:

And that’s how you can get the server memory and cpu usage from PHP. I hope that these function can help someone else along the way.