Deploy PHP Applications

Before deploying a PHP application, there are a number of things that you must prepare, namely:

  • Awanio account
  • ssh public key that has been registered on the Awanio dashboard page
  • git url endpoint to be used for push code. The format is git@awan.io:TEAM/APP_NAME.git
  • awan.yaml file that is placed in the top application folder

After all this is fulfilled, then you can start making applications based on the starter kit that can be cloned from https://github.com/awanio/php-starter-kit

Awan uses PHP version 7 as runtime. For that make sure your application is compatible with this version.

For PHP-based applications, the contents of the awan.yaml file are as follows:

version: '1.0'
web:
  type: php
  version: 7.1
  doc_root: ./public

If you use Composer as a package manager, make sure the composer.json file and the composer.lock file are included in the commit. The following is an example of the minimum contents of the required composer.json file:

{
  "name": "my-team/my-app-name"
}

Following is the example cloud.yml file for PHP with composer:

version: '1.0'
web:
  type: php
  version: 7.3
  doc_root: ./public
  package_manager: composer

doc_root is information about the php file entry point used. Generally this is the location where the index.php file is located.

Sometimes our application requires a worker process that is run before or concurrently with a web application, for example in a Laravel application that requires php artisan migrate and php artisan queue: work. So the example cloud.yml file is:

version: '1.0'
web:
  type: php
  version: 7.3
  doc_root: ./public
  package_manager: composer
  run: php artisan migrate --force & php artisan queue:work & apache2-foreground

Please note, make sure the apache2-foreground command is always at the end of all worker commands.

After the application is ready, add git remote Awanio to the project:

git remote add awan git@awan.io:TEAM/APP_NAME.git

After the application is ready, then please commit and push to the git server to Awanio

git push awan master

After the deployment is complete, please check your application at https://app-name.diawan.id

htaccess file

Awanio uses Apache Httpd as a runtime. This way, you can add the .htaccess file to the application's doc_root folder.