Skip to content

Instantly share code, notes, and snippets.

@bhaidar
Last active July 2, 2023 15:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bhaidar/f9d10004e64d53c7cc5fc79e3f938d72 to your computer and use it in GitHub Desktop.
Setting up a new Laravel application
## Setting up a Laravel application
I started by creating a new Laravel app. There are several methods for creating a new Laravel app. I chose the Docker-based one using the Laravel Sail package. You can read more about Laravel installation by following this URL (https://laravel.com/docs/10.x/installation).
Choose the method that best suits you. Before you start, make sure you have Docker running on your computer.
I'm using a MacBook Pro. I start by running this command:
curl -s "https://laravel.build/laravel-app" | bash
This creates a new Laravel application on your computer under the directory named **laravel-app**.
After the installer finishes, run the following commands:
1. Open the .env file and add the following environment variables:
```
APP_PORT=1012
FORWARD_DB_PORT=4008
FORWARD_MAILPIT_PORT=2012
FORWARD_MAILPIT_DASHBOARD_PORT=2013
FORWARD_MEILISEARCH_PORT=6012
FORWARD_REDIS_PORT=6013
VITE_PORT=1011
```
2. Build up the Docker container.
```
./vendor/bin/sail up
```
3. Install the NPM packages.
```
./vendor/bin/sail npm install
```
4. Serve the application.
```
./vendor/bin/sail run dev
```
The application is now accessible at http://localhost:1012. Open the URL in the browser, and you'll see the same view as in the figure below.
<img width="1240" alt="Figure4" src="https://user-images.githubusercontent.com/1163421/250366198-80dec7c6-bd39-4173-958d-b77c286e8574.png">
Next, let's install the Laravel Breeze starter kit. The Laravel team provides this starter kit for scaffolding Laravel authentication and Profile management. This is my ultimate choice when starting a new Laravel project. Trust me: It saves you a lot of time! You can read more about Laravel Breeze here (https://laravel.com/docs/10.x/starter-kits#laravel-breeze).
## Laravel Breeze Installation
Laravel Breeze comes in four flavors:
- Breeze & Blade
- Breeze & React
- Breeze & Vue
- Breeze & Next.js/API
I'll use Breeze and Vue here. The same installation method applies to the rest of Breeze flavours.
Run the following commands to install Laravel Breeze, VueJS, and InertiaJS together.
```
./vendor/bin/sail composer require \laravel/breeze --dev
./vendor/bin/sail artisan breeze:install vue
./vendor/bin/sail artisan migrate
./vendor/bin/sail npm install
./vendor/bin/sail npm run dev
```
By installing Laravel Breeze, you've installed a ton of new things in your application. Let me list them briefly, but you can always check this repository commit titled (install Laravel Breeze package) to check every new file and configuration added by the package.
In addition to the Breeze Starter Kit, Laravel also offers the JetStream Starter Kit, which is a more advanced option.
More importantly, Laravel Breeze does the following:
- Adds Vue, InertiaJS, and Tailwindcss
- Configures InertiaJS
- Configures Tailwindcss
- Scaffolds a front-end application using Vue/InertiaJS
- Adds Laravel Authentication controllers, views, and routes.
That's it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment