Join Bernard Pineda for an in-depth discussion in this video Setting up the project, part of Laravel 5 Essential Training: 2 Testing, Securing, and Deploying.
- [Instructor] The initial setup of this project includes setting up the database and loading the code. If you already have the database that we created on the previous course, you may skip this step until we open up our code in Visual Studio Code. So let's open up our console and connect to our database. In some systems, it will not require a root password, so we would connect with mysql minus user root. However, we need a password on this specific system and we will do it with mysql minus user root minus proot right next to it.
So let's create our database with create database, landon_app, semicolon, and we've created our database. Now let's create the user we are going to use to connect to this database with create user, single quotes, landon_app, we close single quotes, at, single quotes again, localhost identified by, and the password surrounded by single quotes, landon_app.
Now let's grant all the permission this user needs for the database with grant all on the database landon_app.* to the user, in single quotes, landon_app, single quotes, at localhost, also surrounded by single quotes, semicolon. And now let's exit.
Now let's clear our screen with clear. And let's try to connect with a newly created user with mysql minus user landon_app minus plandon_app and minus capital D landon_app. The capital D is to tell MySQL to connect to that specific database.
And we have no errors. Now we need the code of the working application. So let's open up our desktop and let's open our Resources folder inside our exercise files, and let's go to initial_app and copy the landon_app folder. We'll copy it into our desktop. And now that we have it on the desktop, let's drag it into Visual Studio Code. Let's press cmd + b or ctrl + b.
And we have set up the credentials for the database. They will be on the .env file, and we've already set up landon_app, landon_app, and landon_app for the database, username, and password. Now let's go back to the console. Let's exit the database, clear our screen with clear or cmd + k. Let's navigate into our landon_app folder with cd landon_app, and now let's install our dependencies with composer install.
Let's clear the screen again. Let's clean our cache with php artisan cache:clear. Let's set up our config cache with php artisan config:cache. And now let's run our migrations with php artisan migrate. Now we have our database structure ready. Now we need to import the initial data for our application.
We'll do that going up once and go into our exercise files with ExerciseFiles/Resources/db. Let's clear our screen and import with mysql minus user landon_app, minus capital D landon_app, less than landon_data.sql.
Oh, we have a typo there. We just need the password, also. So we need minus plandon_app, and we just get a warning, but the data has been imported. Now let's go back to our initial application folder. So let's go back to the desktop, and let's go back to the landon_app folder. We really don't need our server running for our test, but let's do a quick run to see if everything is in place.
So let's clear our screen, and let's run php artisan serve. Let's open up on the browser, and as we can see, we are looking at the database data and our application is working correctly.
- Building features with test-driven development
- Authenticating users
- Uploading files
- Deploying Laravel code