A simple command-line tool whose aim is to facilitate the continous delivery of PHP apps

Overview


Deployer

Simple command-line tool that aims to facilitate the continous delivery of PHP apps, particularly Laravel apps. Imagine you want to update your app (in a remote server) when a new commit is pusehd to its repo, but you have no way of ssh'ing into the server or using something like Github Actions. deployer is a cli that can run periodically on the server to check if new code is avaiable, pulling it and executing all the migrations accordingly.

NOTICE: deployer is a homebrewed solution to solve a very specific problem, there are better ways of doing continous delivery.

๐Ÿš€ Usage

Before continuing, make sure you have git, php and composer installed and available.

1. Installation

Clone this repository to a folder in your server (where the to-be-deployed app will run):

git clone --recurse-submodules https://github.com/Dovyski/deployer && cd deployer

Optionally you can make the script globally available to save some typing. First make it executable:

chmod +x deployer.php

Then create an alias for it on your .bash_profile:

> ~/.bash_profile ">
echo "alias dpr='/usr/bin/env php $(pwd)/deployer.php'" >> ~/.bash_profile

Source the alias:

source ~/.bash_profile

Finally check if everything is working as intended:

dpr -v

2. Deployment of an app

deployer expects two folders are available (and writable) to store files, such as database backups and logs, etc. It is highly recommended to create them.

Somewhere in your system, create the working folders:

mkdir {backups,logs}

Assuming your app is stored in the /home/user/apps/myapp (and that it is a cloned git repo), the command to update the app is:

dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder"

That's it! Your app should be up-to-date and running its latest version.

If you want to periodically update the app, making backups before running any migration, you can add the command above to a crontab:

crontab -e

Add the following:

* * * * * dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder"

In that case, deployer will only run migrations, create backups, etc. if the local version of the app is behind the remote repository. If it is even, nothing will happen locally.

3. Advanced usage (optional)

3.1 Init Laravel app

If you are deploying a Laravel app, deployer can be used to init everything for you. In that case, run the following:

dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder" --init="laravel"

3.2 Backup a running app

If you just want to backup the database of an app that is already running, without updating its code or migrating anything, just run:

dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder" --backup-only

3.3 Dry-run

If you are afraid of running anything, you can check what is going to happen by using the --dry-run param:

dpr --app-dir="/home/user/apps/myapp" --backup-dir="/path/to/backups/folder" --log-dir="/path/to/logs/folder" --init=laravel --dry-run

In such case deployer will output all commands it intends to run, however no command will actually be executed.

๐Ÿค Contribute

Your help is most welcome regardless of form! Check out the CONTRIBUTING.md file for all ways you can contribute to the project. For example, suggest a new feature, report a problem/bug, submit a pull request, or simply use the project and comment your experience. You are encourage to participate as much as possible, but stay tuned to the code of conduct before making any interaction with other community members.

See the ROADMAP.md file for an idea of how the project should evolve.

๐ŸŽซ License

This project is licensed under the MIT open-source license and is available for free.

๐Ÿงฌ Changelog

See all changes to this project in the CHANGELOG.md file.

๐Ÿงช Similar projects

Below is a list of interesting links:

Note: Icons made by Flat Icons from www.flaticon.com.

You might also like...
Twitter raffles in the command line, with PHP and minicli
Twitter raffles in the command line, with PHP and minicli

Rafflebird Rafflebird is a highly experimental CLI application for giveaways / raffles on Twitter, built in PHP with Minicli. Disclaimer: The recent s

Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt
Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt

EasyEngine v4 EasyEngine makes it greatly easy to manage nginx, a fast web-server software that consumes little memory when handling increasing volume

Generic PHP command line flags parse library
Generic PHP command line flags parse library

PHP Flag Generic PHP command line flags parse library Features Generic CLI options and arguments parser. Support set value data type(int,string,bool,a

๐Ÿƒ In short, it's like Tailwind CSS, but for the PHP command-line applications.
๐Ÿƒ In short, it's like Tailwind CSS, but for the PHP command-line applications.

Termwind Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API. In short, it's like Tailwind CSS

php command line script to DCA crypto from Coinbase Pro

dca.php A simple php script designed to be run via the command line via a cron job. This will connect to coinbase pro and buy the crypto coins specifi

A PHP library for command-line argument processing

GetOpt.PHP GetOpt.PHP is a library for command-line argument processing. It supports PHP version 7.1 and above. Releases For an overview of the releas

BetterWPCLI - a small, zero-dependencies, PHP library that helps you build enterprise WordPress command-line applications.
BetterWPCLI - a small, zero-dependencies, PHP library that helps you build enterprise WordPress command-line applications.

BetterWPCLI - a small, zero-dependencies, PHP library that helps you build enterprise WordPress command-line applications.

Command-Line Interface tools

Aura.Cli Provides the equivalent of request ( Context ) and response ( Stdio ) objects for the command line interface, including Getopt support, and a

Another Command Line Argument Parser

Optparse โ€” Another Command Line Argument Parser Install 1. Get composer. 2. Put this into your local composer.json: { "require": { "chh/optparse

Releases(v1.0.0)
Owner
Fernando Bevilacqua
Lecturer of Computer Science, researcher, former gamedev, currently a developer gone rogue. Passionate about everything open-source (and โ˜•๐Ÿฐ).
Fernando Bevilacqua
Simple command-line tool to access HiWeb account information

Simple command-line tool to access HiWeb account information.

Milad Nekofar 2 Dec 26, 2022
PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal.

PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal. ??

Nuno Maduro 32 Dec 26, 2022
Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check. Installation / Usage Requires PHP 8.0+ First, install Patr

Nuno Maduro 237 Nov 14, 2022
A PHP command line tool used to install shlink

Shlink installer A PHP command line tool used to install shlink. Installation Install this tool using composer.

null 8 Nov 3, 2022
A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

Front End Compiler A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies. The minif

Happy Medium 2 Nov 12, 2021
๐Ÿ‘จ๐Ÿปโ€๐Ÿš€ A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ๐Ÿš€

Alpine Day Schedule a command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, instal

Nuno Maduro 11 Jun 10, 2021
Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone.

Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, install: c

Nuno Maduro 101 Sep 16, 2022
๐Ÿ’ฅ Collision is a beautiful error reporting tool for command-line applications

Collision was created by, and is maintained by Nuno Maduro, and is a package designed to give you beautiful error reporting when interacting with your

Nuno Maduro 4.2k Jan 5, 2023
Lovely PHP wrapper for using the command-line

ShellWrap What is it? It's a beautiful way to use powerful Linux/Unix tools in PHP. Easily and logically pipe commands together, capture errors as PHP

James Hall 745 Dec 30, 2022
A PHP library for command-line argument processing

GetOpt.PHP GetOpt.PHP is a library for command-line argument processing. It supports PHP version 5.4 and above. Releases For an overview of the releas

null 324 Dec 8, 2022