Deploy your PHP code

Overview

php-deploy

Deploy your PHP code, e.g. to a shared hosting.

The only requirement on the deployment destination server is PHP and the ZIP extension.

Usage

  • composer require allestuetsmerweh/php-deploy
  • Create a file Deploy.php, containing a class implementing AbstractDefaultDeploy (or AbstractDeploy)
  • Run PASSWORD=$DEPLOY_PASSWORD php ./Deploy.php --environment=prod --username=$DEPLOY_USERNAME to deploy

Filesystem structure on the deployment destination server

Definitions:

  • $SECRET_ROOT: The root directory for content not to be accessible via HTTP(S).
  • $PUBLIC_ROOT: The root directory for content to be accessible via HTTP(S).
  • $DEPLOY_DIR: The directory name for the deployments. Default: deploy.
  • $RANDOM_DIR: A random name for a directory, which does not exist yet in the parent directory.

Usages:

  • $PUBLIC_ROOT/$RANDOM_DIR/deploy.zip: The zipped contents of the deployment.
  • $PUBLIC_ROOT/$RANDOM_DIR/deploy.php: The script to unzip and install the deployment.
  • $SECRET_ROOT/$DEPLOY_DIR/candidate/: The directory to unzip the deployment to
  • $SECRET_ROOT/$DEPLOY_DIR/live/: The directory where the current deployment is stored
  • $SECRET_ROOT/$DEPLOY_DIR/previous/: The directory where the previous deployment is stored

CI on github.com

Example .github/workflows/deploy-prod.yml:

on:
  push:
    branches:
      - main
name: Deploy:prod
jobs:
  # TODO: Tests

  deploy-prod:
    name: Deploy to my-domain.com
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: shivammathur/setup-php@v2
      with:
        php-version: '8.1'
    - name: Get composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"
    - name: Cache dependencies
      uses: actions/cache@v1
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
        restore-keys: ${{ runner.os }}-composer-
    - name: Install dependencies
      run: composer install --prefer-dist
    - name: Deploy
      env:
        USERNAME: ${{ secrets.DEPLOY_USERNAME }}
        PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}
      run: php ./Deploy.php --environment=prod --username="$USERNAME"

CI on bitbucket.org

Example bitbucket-pipelines.yml:

image: php:8.1.1
pipelines:
  default:
    - parallel:
      - step:
          name: 'Build and Test'
          script:
            - echo "Your build and test goes here..."
      - step:
          name: 'Lint'
          script:
            - echo "Your linting goes here..."
      - step:
          name: 'Security scan'
          script:
            - echo "Your security scan goes here..."

    - step:
        name: 'Deployment to Production'
        deployment: production
        trigger: 'manual'
        script:
          - apt-get update && apt-get install -y libzip-dev
          - docker-php-ext-install zip
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
          - PASSWORD=$DEPLOY_PASSWORD php ./Deploy.php --environment=prod --username=$DEPLOY_USERNAME
You might also like...
LaraNx Seo enables your Laravel app to store SEO and social media meta tag data in database instead of your code
LaraNx Seo enables your Laravel app to store SEO and social media meta tag data in database instead of your code

LaraNx Seo enables your Laravel app to store SEO and social media meta tag data in database instead of your code. Moving marketing data out of your code base and into your database where it is easily modified.

Testing your OpenApi documentation and your code easily.

Raven - How to test your API documentation and behavior. This library was written to allow testing OpenAPI documentation easily. It also allows verify

Easily add logs anywhere in your Magento 2 code

Magento 2 Simple Log Easily add logs anywhere in the code (like Magento 1). Requirements Requires Magento 2 in any version. Installation Add the Log.p

A self-hosted alternative to putting your code snippets on Gist.
A self-hosted alternative to putting your code snippets on Gist.

WP-Gistpen Contributors: JamesDiGioia Donate link: http://jamesdigioia.com/ Tags: gist, code snippets, codepen Requires at least: 5.2 Requires PHP: 5.

Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.
Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project.
Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project.

ConfigStruct Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project. It

A few Fat-Free specific extensions for Tracy Debugger to help debug your code quickly.

Fat-Free Tracy Extensions This is a set of extensions to make working with Fat-Free a little richer. F3 - Analyze all hive variables. Database - Analy

Code to accompany the YouTube video "Full PHP cURL API tutorial - how to use a REST API from PHP using cURL"

PHP cURL CRUD Example Example code to accompany this YouTube video. Note that the init_curl.php file contains a placeholder for an API key. DO NOT che

The VarExporter component allows exporting any serializable PHP data structure to plain PHP code.

The VarExporter component allows exporting any serializable PHP data structure to plain PHP code. While doing so, it preserves all the semantics associated with the serialization mechanism of PHP (__wakeup, __sleep, Serializable).

Comments
  • Think about a pull-based solution

    Think about a pull-based solution

    Flow:

    • Build the dist ZIP file on some CI (e.g. GitHub Actions)
    • User uploads an install.php file to their FTP server
    • User runs the install.php file from a browser
    • install.php downloads code (e.g. dist ZIP from GitHub)
    • install.php asks user to configure deployment:
      • Non-public files path
      • Database
      • Other
    • install.php installs the deployment
    • In the future, use install.php to upgrade code
    opened by allestuetsmerweh 0
Owner
Simon Hatt
Simon Hatt
Learn how to deploy Laravel 7 project in GCP from scratch

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Almujeer Uddin 2 Nov 21, 2021
Hachkathon DevOps - Deploy application with docker container

Hackathon-Semesta-DevOps Nama : Islam Nurul Yakin Mail : [email protected] Sebuah Web Server menggunakan Nginx, PHP, dan MySQl di tambah dengan p

Islam Nurul Yakin 3 Jul 14, 2022
Preload your sweet sweet code to opcache with a composer command, making your code faster to run.

Composer Preload Preload your sweet sweet code to opcache with a composer command, making your code run faster. Composer Preload is a composer plugin

Ayesh Karunaratne 197 Dec 6, 2022
The SensioLabs DeprecationDetector runs a static code analysis against your project's source code to find usages of deprecated methods, classes and interfaces

SensioLabs DeprecationDetector CAUTION: This package is abandoned and will no longer receive any updates. The SensioLabs DeprecationDetector runs a st

QOSSMIC GmbH 389 Nov 24, 2022
Result of our code-along meetup writing PHP 8.1 code

PHP 8.1 Demo Code This code demonstrates various PHP 8.0 and 8.1 features in a realistic, functional (but incomplete) codebase. The code is part of so

azPHP 2 Nov 14, 2021
Dead Code Detector (DCD) for PHP code.

This project is no longer maintained and its repository is only kept for archival purposes. PHP Dead Code Detector (PHPDCD) phpdcd is a Dead Code Dete

Sebastian Bergmann 406 Dec 30, 2022
⚗️ Adds code analysis to Laravel improving developer productivity and code quality.

⚗️ About Larastan Larastan was created by Can Vural and Nuno Maduro, got artwork designed by @Caneco, is maintained by Can Vural, Nuno Maduro, and Vik

Nuno Maduro 4.4k Jan 4, 2023
Free ZIP Code API - Free Access to Worldwide Postal Code Data

About Zipcodebase - Free Zip Code API Zipcodebase is a zip code API that was founded in 2019 to solve common issues with postal code data. As we have

SaaS Industries 2 Nov 26, 2022
Webman quickly creates a verification code tool similar to Google verification code

webman-captcha-grid webman quickly creates a verification code tool similar to Google verification code webman 快速创建一个类似于 Google 点图验证码的本地验证码扩展 介绍 webma

听风吹雨 6 Dec 5, 2022