Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

project setup

ScrambledRK edited this page Jul 28, 2017 · 22 revisions

This web project is developed using php/laravel with a postgres database for the backend and angular js (1) for the frontend. Package and build management used are composer for the backend and bower for the frontend as well as gulp/elixir for asset management. composer requires a working php environment. Bower and gulp require nodejs with npm.

Installation

The laravel backend framework provides a vagrant box (Homestead) that provides the required software for this project. Software frameworks and libraries must be installed regardless.

required software:

  • web server (e.g. Nginx)
  • php 5+ interpreter
  • postgres database
  • node js

docker server

As an alternative to installing the required software and frameworks locally you can leverage a mounted docker container to install the project and run the server using the provided docker-composer.yml and .env.sample. This process also starts the server.

  1. rename the .env.sample file to .env
  2. replace arguments enclosed in brackets (Github Access Token)
  3. execute the following powershell commands in the project directory
docker-compose up -d

$con = ("" + (docker ps | sls laravel)).Substring(0,6)
docker exec -it $con bash
  1. install required frameworks/libraries through the docker container

required frameworks/libraries

Regardless how you run the required software, you need to install project specific framework and library dependencies. Package handler and task runner are available for this setup process.

important frameworks/libraries: Laravel, Angular JS, Angular JS Material, Leaflet JS
build tools: composer, bower, gulp, npm

composer update --no-scripts
composer install
npm install -g gulp bower
npm install && bower install --allow-root

php artisan migrate --force
php artisan db:seed --force
gulp

Running and Debugging

Javascript, css and assets are transformed by the provided build scripts. Gulp must build the project for changes to have effect. Default ports for various services can be inspected in the docker-compose.yml file.

project structure:

  • angular - frontend javascript, newhere specific
  • app - backend php, laravel framework, newhere specific
  • config - backend php, laravel framework, startup related
  • database - backend postgres, newhere specific
  • storage - containing server logs, cache, etc.
  • public - webserver root directory

using provided docker image: mapping is from local project folder to /var/www/laravel

backend: php

The provided dockerfile will install and configure xdebug to the php container when built. You need to set both host and idekey in your .env file for xdebug. Default values can be inspected in the provided dockerfile. Default xdebug port is 9000.

  • PHP_XDEBUG_ENABLED=1
  • XDEBUG_CONFIG="idekey=PHPSTORM remote_host=192.168.1.100"

remote_host is the network address of your local machine you want to debug on. idekey is a sessionkey sent through the browser to the server for xdebug to do its magic. There are many ways to set this up, including browser plugins. learn more here.


Troubleshooting

  • Whoops, looks like something went wrong.

    • change/add 'APP_DEBUG' in .env file to 'true'
  • An error occurred while removing the VCS metadata: Could not delete [...].git/ [...]

    • file might be locked (e.g. tortoise git cache process); composer installation is still successful
  • production.ERROR: RuntimeException: Unable to boot ApiServiceProvider, configure an API domain or prefix. in /var/www/html/[...]/DingoServiceProvider.php

    • change/add 'API_PREFIX' in .env file to 'api'
  • production.ERROR: RuntimeException: No supported encrypter found. The cipher and / or key length are invalid. in /var/www/html/[...]/EncryptionServiceProvider.php

    • change/add 'APP_KEY' in .env file to a random, 32 character string (and restart server)
  • notify-send must be installed on the system.

    • npm install gulp-notify; the gulp process should have been successful regardless of this error
  • possibly unhandled rejection: {"data":{"message":"SQLSTATE[42P01]: Undefined table: 7 ERROR: relation \"languages\" does not exist [...]

    • server started without database migration
      execute in docker container: php artisan migrate --force
  • SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint [...]

    • execute in docker container: php artisan migrate:refresh --seed
  • ide is waiting for xdebug connection using docker/ xdebug host is wrong using docker

    • you may need to add a space after the opening quote and before the closing quote in your *.env file. xdebug properties are correctly set but the first and last character of the XDEBUG_CONFIG property value of your *.env file is parsed as part of the value as well. however it did not work without quotes. adding spaces works around this issue.
Clone this wiki locally