DEV Community

Cover image for Starting your first Laravel project
Chris Bongers
Chris Bongers

Posted on • Originally published at daily-dev-tips.com

Starting your first Laravel project

Today I'll be showing you how easy it is to get started with a Laravel project.

Laravel is a PHP framework. For me, it focuses on good practices and clean code.

The super cool part about Laravel 8.0 is that it now comes with a simple terminal command to build an app that runs in Docker!

Before we start, make sure you have Docker desktop installed.

Download Docker desktop

Installing Laravel

Once you have Docker installed and setup, we can open the terminal and execute the following command.

curl -s https://laravel.build/laravel-app | bash
Enter fullscreen mode Exit fullscreen mode

Running this command will create a laravel-app folder in the current folder you in.

You can change the name to whatever you need it to be, so your projects need to be called client-website run the following command.

curl -s https://laravel.build/client-website | bash
Enter fullscreen mode Exit fullscreen mode

With this command, it will setup all the packages and even set your application key for you.

To run the application, we can simply cd into the directory and run the following command.

cd laravel-app
./vendor/bin/sail up
Enter fullscreen mode Exit fullscreen mode

The first time the sail up command will take quite a while but don't worry any time after that, it will be quick.

Note: If you're on the new Mac M1, you need to change the docker-compose.yml file. Change image: 'mysql:8.0' to image: mariadb:10.5.8

Once everything is installed, you should see the following in your Docker desktop app.

Screenshot 2021-02-16 at 08.21.49.png

And we should be able to view the application going to http://localhost.

Note: you might have to change the port if you already have a server running on port 80

Laravel app running via Docker

And we even get a default Mailhog installation on port 8025:

Screenshot 2021-02-16 at 08.21.34.png

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Top comments (4)

Collapse
 
leob profile image
leob

Too easy ;-) what happened to installing and configuring PHP and Apache and whatnot in the old way? :-)

Collapse
 
dailydevtips1 profile image
Chris Bongers

Haha pfew luckily we don't have to deal with that mess anymore 😂
Still have to on certain servers and it's such a pain

Collapse
 
leob profile image
leob

So what's this new thing using under the hood, is it based on Nginx?

Thread Thread
 
dailydevtips1 profile image
Chris Bongers

It's Docker, Think by default Nginx under the hood, but stand to be corrected on that.