# Laravel Deployer - The Ultimate Deployment Tool for Your Laravel Application

Are you tired of manually deploying your Laravel application every time you make a change to your codebase? Do you want to automate your deployment process to save time and avoid human errors? If yes, then Laravel Deployer is the perfect tool for you.

### Deployer Link: [*https://github.com/sohag-pro/laravel-deployer*](https://github.com/sohag-pro/laravel-deployer)

Laravel Deployer is an open-source deployment tool that helps you automate the deployment process of your Laravel application. With Laravel Deployer, you can easily deploy your application to different environments such as production, staging, and development.

In this blog post, we will discuss what Laravel Deployer is, how it works, and how you can use it to automate your deployment process.

### What is Laravel Deployer?

Laravel Deployer is a deployment tool that helps you automate the deployment process of your Laravel application. It uses a simple configuration file to define your deployment strategy and performs the deployment process automatically.

Laravel Deployer is specifically designed for Laravel applications and comes with many Laravel-specific features.

### Best Features:

* No downtime deployment
    
* Reverse to the previous deploy
    
* MySQL Backup
    
* Restore MySQL from backup
    
* UI of the Deployer
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683198012948/779395a1-89e6-44be-9a95-3d32322a8504.jpeg align="center")

### How does Laravel Deployer work?

Laravel Deployer works by creating a new deployment and then making a symbolic link to the server root. It also allows you to write deployment-specific commands, like running migrations or seeders.

## How to setup Laravel Deployer

* Clone the repository
    

```bash
git clone https://github.com/sohag-pro/laravel-deployer.git
```

* Install dependencies
    

```bash
composer install
```

* Create a copy of your .env file
    

```bash
cp .env.example .env
```

* Generate an app encryption key
    

```bash
php artisan key:generate
```

* put the env variable in .env file
    

```bash
GIT_REMOTE_URL=https://github.com/sohag-pro/laravel-deployer.git
# full path from root from where the project will be server
# with a trailing slash
SERVE_DIR=/Users/sohag/Projects/deployer-test/www/

# full path from root from where the project will be cloned and all other operations will be done
# Should be different from SERVE_DIR and should be created manually before running the script
# with a trailing slash
BASE_DIR=/Users/sohag/Projects/deployer-test/

# where the backups will be stored
VERSION_DIR=backups

# where the storage will be linked
STORAGE_DIR=storage

# Where the dump SQL will be stored
DB_DIR=database

# which db to dump
DEPLOYER_DB_NAME=

# user to dump db
DEPLOYER_DB_USER=

# password to dump db
DEPLOYER_DB_PASSWORD=
```

* Run the local development server
    

```bash
php artisan serve
```

* Visit [http://localhost:8000](http://localhost:8000) in your browser
    

## How to add deployment-specific commands?

Just create a file in your project root named `afterDeploy.sh` and all your commands there. All of them will be executed on the deployment.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683198423761/46869ecb-9bb3-438e-bc1d-5c73e87e4d0b.jpeg align="center")

The [repo](https://github.com/sohag-pro/laravel-deployer) is actively looking for contributions, if you can do some contributions, please have a look.

Thank you for your interest.
