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:
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.
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.
To create a new Laravel application right click on the Laragon interface and choose Quick app > Laravel.
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.
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.
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.
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.
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:
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.
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:
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.
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.
No subscriptions, no auto-renewals.
Just a simple one-time payment that helps support my free, to-the-point videos without sponsered ads.
Unlocking gets you access to the notes for this video plus all 200+ guides on this site.
Your support is appreciated. Thank you!