Skip to content

DerHerrFeldmann/laravel-openshift

 
 

Repository files navigation

Laravel 5.6 Quickstart on OpenShift

Laravel is a free, open source PHP web application framework, designed for the development of model–view–controller (MVC) web applications.

This quickstart was created to make it easy to get started with Laravel 5.6 on OpenShift v3.

The simplest way to install this application is to use the OpenShift quickstart template.

To install the quickstart, read my blog on Medium.

Installation

  1. Create an OpenShif account

  2. Install the OpenShift CLI tools

  3. Add the Laravel template(s) to your project:

    $ oc create -f https://raw.githubusercontent.com/matriphe/laravel-openshift/master/openshift/templates/laravel-mysql.json
    

    or

    $ oc create -f https://raw.githubusercontent.com/matriphe/laravel-openshift/master/openshift/templates/laravel-postgresql.json
    

    or

    $ oc create -f https://raw.githubusercontent.com/matriphe/laravel-openshift/master/openshift/templates/laravel-sqlite.json
    
  4. Fork this GitHub repo

  5. From the your OpenShift image catalog, select Laravel + MySQL (persistent) image

  6. Replace the Git Repository URL using this repository or your forked repository

  7. Scroll to the bottom of the page and click [ Create ] to deploy your application

  8. Follow these instructions to configure automated builds, allowing you to push your code to your GitHub repo and automatically trigger a new deployment

  9. Since Laravel 5.6 required PHP 7.1, the default PHP image used in the image was 7.0, so you have to change the base image from the Builds page on the Builds image and use openshift/php:7.1 or openshift/php:latest image

OpenShift Considerations

These are some special considerations you may need to keep in mind when running your application on OpenShift.

Local vs. Remote Development

This Laravel quickstart provides separate configuration files for both local and remote development. Use .env for local development, and .s2i/environment for remote development.

Remote Development

Your application is configured to automatically use an OpenShift MySQL, PostgreSQL, or SQLite database in when deployed on OpenShift using the included templates (see openshift/templates).

Additionally, your APP_ENV, APP_URL, and APP_KEY can be set by following the installation instructions with the included templates.

Laravel Migrations

The php artisan migrate --force command is automatically executed during deployment when using any of the included templates (see openshift/templates).

Composer

During the build process, composer install is automatically executed over the root directory. See the PHP 5.6 builder image for more details, or more specifically see here.

Development Mode

By default, this Quickstart is configured in development mode to make debugging your application easier.

When you develop your Laravel application in OpenShift, you can also enable the production environment by setting environment variables, using the oc client, like:

$ oc get services
NAME                     CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
laravel-mysql-example   172.30.79.234   <none>        8080/TCP   23m
$ oc set env dc/laravel-mysql-example LARAVEL_APP_ENV=production LARAVEL_APP_DEBUG=false OPCACHE_REVALIDATE_FREQ=2

Next, run oc status to confirm that an updated deployment has been kicked off.

For more information on environment variables impacting PHP behavior on OpenShift, see the PHP 7.1 builder image.

For more information on Laravel environment variables, see the Laravel environment configuration documentation.

Log Files

Your application is configured to use the OpenShift log directory. You can use the oc logs command to stream the latest log file entries from your running pod:

$ oc get pods
NAME                             READY     STATUS      RESTARTS   AGE
laravel-mysql-example-1-build   0/1       Completed   0          26m
laravel-mysql-example-1-hj2k1   1/1       Running     0          23m
$ oc logs laravel-mysql-example-1-hj2k1

To stop tailing the logs, press Ctrl + c.

Additional Resources

Documentation for the Laravel framework can be found on the Laravel website. Check out OpenShift's Documentation for help running PHP on OpenShift.

About

Laravel Example for OpenShift 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 95.8%
  • HTML 3.4%
  • Other 0.8%