Laravel
Introduction
Laravel is a PHP framework for creating apps. This install will get the basic app going once done read the next steps
Getting Started
- First create a new GitLab project using the instance template from the AppBase for your language (PHP).
- The AppBase will provide you with a pattern to deploy applications
- Will automatically setup GitLab CI/CD tools such as security settings
- The quickest way to get up and running with OpenShift.
- Read the README.md file in the repository for latest instructions and notes for your framework.
TODO:
- OpenShift notes
Install
To setup Laravel in this repository start with a new application starter-kit. To run the initial install you will need Docker running locally.
For git code editing after make sure to also have composer installed and a recent version of PHP.
In the git repository folder
curl -s https://laravel.build/example-app | bash
cp -Rp example-app/* example-app/.g* example-app/.e* example-app/.s* .
rm -rf example-app
git add .
Documentroot
Laravel uses public as the root folder so we need to change the default folder from web to public
vi .s2i/environment
Change DOCUMENTROOT line to
DOCUMENTROOT=/public
Launching
When you use Laravel you have to set an app encryption key. To generate a new one to dump into the .env file.
php artisan key:generate
Copy all the existing environment settings into the s2i environment (make sure the app_key isn't checked in. If you do regenerate it and add it to an environment variable not the file).
cp .env >> .s2i/environment
Notes
Permissions fixes
Apache needs write access to the storage folder
chmod -R 777 storage
MySQL fixes
For older MySQL you will get the error
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))
To fix this set the limit in the app/Providers/AppServiceProvider.php to add the use schema line and to set the limit in the boot up sequence.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
//
}
}