It is time to work with Migrations and build up our database so that we can store our posts. In the last video we created the Model through our terminal and we told Laravel to also create a migration while it was at it. Now its time to explore migrations and how they work.
Basically Migrations work as a step by step instructions on how to create database structure. Every time we make a new migration we give it new instructions on how to change the database. This might mean creating a new database table, or adding and removing columns. Every migration will have two functions:
1) Public Function Up( ) - this is the function that migrations use when building up the database.
2) Public function Down( ) - this is for the instructions on how to build down the database in case we need to go backwards.
In order to use Migrations we need to make sure we have our database set up locally on our computer and then we need to put our database settings into Laravel so it can connect to it. Throughout this series we will be using MySQL as our database. This means you need to install MySQL if you haven't already. Links to install are below. In addition it is usually useful to have a way to manage our databases or to view them. I prefer using Sequel Pro for Mac to view and edit my database, but if you are on windows then please look at MySQL Workbench. Both of these programs are free and the links are below.
Once we have our database setup, it is time to run the migration. Look at the code snippet below to see how to run the migration.
In the next video we will create a form to submit new blog posts to be stored into our database that we created in this video.
--- MORE FROM THIS SERIES ---
Previous Video [Part 8]: https://youtu.be/0xvB6h5-jtI
Next video [Part 10]: Coming Soon
Full Playlist for the "How to Build a Blog with Laravel" Series: https://www.youtube.com/playlist?list=PLwAKR305CRO-Q90J---jXVzbOd4CDRbVx
--- LINKS ---
Laravel Docs About Migrations: https://laravel.com/docs/5.2/migrations
Download MySQL: http://dev.mysql.com/downloads/mysql/
Download Sequel Pro (Mac Only): http://www.sequelpro.com/
Download MySQL Workbench (Mac, Linux, Windows): http://dev.mysql.com/downloads/workbench/
--- TROUBLESHOOTING ---
If you have trouble connecting to your database then you might want to try to change the database URL first. If 127.0.0.1 doesn’t work then try localhost and see if that works. Also if you had MySQL previously installed then you might have changed the username and password outside the defaults. If that is the case then you need to obviously update those fields in your .env file to reflect the correct user and password information.
--- FOLLOW ME ---
Twitter - http://twitter.com/_jacurtis
Tags: Laravel 5 Framework Tutorial Easy to learn. Best tut about Laravel. Build a blog with Laravel Tutorial. Beginner tutorial. How to video. PHP framework easy best tutorial. MySQL database with migrations using Laravel 5.2 in a good tutorial series.