← Other topics

New Laravel app on Laragon

Video Notes

Laragon is an all-in-one development program with a user-friendly interface that includes the essential ingredients needed to build a Laravel application including:

  • Apache web server (Laragon can also run Nginx if you prefer)
  • PHP
  • MySQL database server
  • Composer dependency management

In this guide we’ll learn how to set up Laragon and create a new Laravel application.

Laragon runs on Windows. If you're looking for a Mac server solution, check out: New Laravel application with Herd and DBngin.

Download and install

To get started, download and install Laragon Full from https://laragon.org/download.

Once Laragon is installed and running, click Start all to start the Apache and MySQL servers.

Start the Apache and MySQL servers in Laragaon after installing

New Laravel App

To create a new Laravel application right click on the Laragon interface and choose Quick app > Laravel.

Create a new Laravel app in Laragon using the "Quick App" feature

This will prompt you for an application name then pull up a command line window where it will complete the process for creating a new Laravel application.

The resulting application will exist at C:/laragon/www/demo (where demo is whatever you named your application).

By default, the application should be accessible via a .test domain, e.g. http://demo.test.

Resulting output of installing Laravel including the path and domain

Fixing the document root

When we load http://demo.test in the browser, we should see the new welcome page every new Laravel application is set up with. Instead we see the directory contents of our project.

Directory contents of Laravel appliction instead of default welcome page

The reason for this is Laragon set the document root for our new application to c:\laragaon\www\demo, but it should be set to the public subdirectory at c:\laragon\www\demo\public.

To fix this, right click on the Laragon interface and choose Apache > sites-enabled > dir: sites-enabled to open your sites enabled directory.

Locating sites enabled for Apache in Laragon

This is where Apache configs are places for any sites you create in Laragon. Within this folder you should see a file called auto.demo.test (where demo is the name of the application you created). Open this file and update the two lines that reference C:/laragaon/www/demo so that they are set to C:/laragaon/www/demo/public.

Adding the public directory to Apache sites-enabled in Laragon

After saving your changes, restart your Laragaon servers by clicking Stop followed by Start all.

Now when you load your application in the browser you should see the default Laravel welcome page:

Welcome page for a new Laravel app generated in Laragon

Database config

Next we’ll confirm our application can communicate with a database on Laragon’s MySQL database server.

Within your application’s code base, open the .env file and locate the database configs which are all prefixed with DB_. The settings you see here should work “out of the box” as they match the default configs/credentials the Laragon MySQL database server uses. You can change DB_NAME from the default of laravel to something more specific to your application.

Checking database configs within Laravel’s .env file

Now that we’ve checked our settings, we can confirm our database connection by attempting to run our application’s migrations. Migrations are code files used in Laravel to describe the structure of our application’s database tables.

Open a command line window by clicking the Terminal button from the Laragon interface. Change into your application directory (e.g. cd demo) and run the command php artisan migrate to run your migrations. When it asks if you want to create the dtabase, type yes and hit enter.

If all went well, you should see that your migrations succesfully ran:

Running migrations in Laravel application to test MySQL database connection

MySQL command line mode

To confirm your database was set up correctly, we can enter MySQL command line mode with the command mysql -u root.

Once at the MySQL command prompt run the command SHOW DATABASES;. Amongst some default system databases, you should see your new database.

Run the command USE demo; (swap in demo with the name of your database) to select that database then SHOW TABLES; to view the tables in that database.

You should see several default Laravel database tables that were constructed by your migrations.

You can run the command exit; to leave the MySQL command prompt.

MySQL command line mode to confirm database was created

Conclusion

To edit the contents of what you see when you visit your site, edit the file /resources/views/welcome.blade.php within your applicaction.

Of course, there are many more customizations you’ll want to make to your application, but what we’ve covered in this guide was everything you needed to initialize a new Laravel application and database using Laragon. If you're on the path to learning how to work with Laravel, check out my series Laravel - In a Nutshell.

If this info helped you out you can say thanks and support future content by clicking my Amazon affiliate link: https://amzn.to/3UtgnYk. If you make a purchase on Amazon within 24 hours of clicking the link I may receive a micro-commission and it costs you nothing extra. Any income from these sales goes directly to supporting me in making new videos and guides. Thank you for your support!

← Other topics