Create Database and Add Environment Credentials3:38 with Jonathan Barrios
To start using Laravel, you'll need Composer, a PHP development tool that manages packages and libraries on your computer. Check the teacher's notes below to learn more about Composer. You'll also need a local development environment such as MAMP, which we’ll be using throughout this course. Besides Composer and MAMP, you’ll need a code editor like Visual Studio Code, which is what I’ll be using in this course. Check the notes below for instructions on how to set those up.
Now that your application folder is open in Visual Studio code, let's create a new 0:00 MySQL database using phpMyAdmin by clicking on Tools, 0:05 then phpMyAdmin. 0:11 Next, create a database by clicking on the Databases tab. 0:15 Name the database, click Create, then navigate to the phpMyAdmin homepage. 0:20 Let's also create a new user under user accounts by clicking Add user, 0:28 then entering a username such as laravel_admin. 0:34 Select Local for Host name and create or generate a secure password. 0:39 Note that you can also decide not to use a password since we're working locally. 0:47 But make sure that any database and user has a secure password while in production. 0:52 That is to say, when hosting the application live on the internet. 0:58 Once you created a user, click on User accounts, 1:06 then click on Edit privileges for the user you just created. 1:09 Next, inside of Global privileges, select Check all, 1:14 then click on Go to save your changes. 1:18 Finally, click on Databases and select the database you created earlier and click Go. 1:23 Out of the box, Laravel provides us with an ENV file to configure our project, 1:36 which we'll need to update with our new database, user, and 1:41 password in these fields. 1:45 If you installed PHP and MySQL using Homebrew, 1:52 you may need to add this as well. 1:55 Next, save your changes and head to the Terminal. 2:01 You can also use the integrated Terminal in Visual Studio Code as well. 2:05 Finally, to confirm that our database credentials are indeed correct, type, 2:09 php artisan migrate. 2:14 If your database credentials are correct, you should see something like this. 2:18 The moment of truth. 2:24 Start up your brand new Laravel app. 2:26 Laravel includes a command line interface named Artisan, which makes it 2:29 easy to serve up your web pages using your local development environment. 2:33 Serve up your site using the following command and flag. 2:38 After executing the above command, 2:43 Artisan will run your very own Laravel application in a web browser. 2:46 Navigate to the URL started by Artisan, which should look something like this URL. 2:51 The default configuration for 2:56 map uses ports 8888, 8889, and 7888. 2:59 So check the teacher's notes on how to change the default port settings. 3:04 Congrats, you got a local development environment up and running. 3:09 You created a Laravel project and 3:14 displayed it in the browser using Artisan CLI. 3:16 On top of that, you updated your application environment credentials and 3:20 tested your new user and database connection. 3:25 In the next section, we'll cover all of the essential files and 3:28 respective folder structures that make up a Laravel application. 3:32 See you there. 3:36
You need to sign up for Treehouse in order to download course files.Sign up