insanitymeetshh/file-sharing

File Sharing - InsanityMeetsHH

3.9.1 2021-02-28 12:36 UTC

README

This git is for fs.imhh.me. Take a look at screenshots.

This application based on Slim Skeleton and Gulp Skeleton.

Table of contents

Included

Install Production Build (Recommended)

Required

  • PHP >= 5.5.9
  • MySQL 5 (pdo_mysql)

Download zip if you don't have git or composer on your OS. Open console on your OS and navigate to your project folder.

$ php composer create-project insanitymeetshh/file-sharing file-sharing "dev-production"
$ (optional) git clone https://github.com/InsanityMeetsHH/file-sharing.git
$ cd file-sharing
$ (optional) git checkout production
$ (optional on unix) rm -rf .git
$ (optional on windows) rmdir .git /s
$ (optional) cp config\additional-settings.dist.php config\additional-settings.php
$ ---- Open "config\additional-settings.php" and change everything you have to change ----
$ php doctrine dbal:run-sql "CREATE DATABASE imhh_file_sharing"
$ php doctrine orm:schema-tool:update --force
$ php doctrine dbal:import sql/all-records.sql

Default Website login: user = user, pass = password If you need PHP, MySQL and Adminer, you have to click here.

Install Master/ Develop Build

Required

  • Node.js
  • npm $ npm i npm@latest -g
  • gulp-cli $ npm i gulp-cli@latest -g
  • PHP >= 5.5.9
  • MySQL 5 (pdo_mysql)

Download zip if you don't have git on your OS. Open console on your OS and navigate to your project folder.

$ php composer create-project insanitymeetshh/file-sharing
$ (optional) git clone https://github.com/InsanityMeetsHH/file-sharing.git
$ cd file-sharing
$ (optional) git checkout develop
$ (optional on unix) rm -rf .git
$ (optional on windows) rmdir .git /s
$ npm i
$ gulp build
$ (optional) cp config\additional-settings.dist.php config\additional-settings.php
$ ---- Open "config\additional-settings.php" and change everything you have to change ----
$ php doctrine dbal:run-sql "CREATE DATABASE imhh_file_sharing"
$ php doctrine orm:schema-tool:update --force
$ php doctrine dbal:import sql/all-records.sql

Default Website login: user = user, pass = password

Install PHP, MySQL and Adminer (optional)

Required

Open console on your OS and navigate to the unziped/ cloned app folder.

$ (unix) systemctl docker start
$ (windows) "c:\path\to\Docker Desktop.exe"
$ docker-compose build
$ docker-compose up -d
$ (optional) ---- Add '"platform": {"php": "7.4.2"}' to "config" in composer.json ----
$ ---- Follow the 4 steps from "Command-line installation" on https://getcomposer.org/download/ and replace every leading "php" with "docker exec -ti file-sharing-webserver php" ----
$ docker exec -ti file-sharing-webserver php composer.phar install
$ docker inspect file-sharing-db 
$ ---- search for "IPAddress" from "DIRNAME_default" (at the bottom) and set IP as Doctrine "host" in "config\additional-settings.php" ----

Open localhost:3050 for Website or localhost:9999 for Database GUI. Database GUI login: user = root, pass = rootdockerpw, host = IP from IPAddress.

Project Commands

Description
gulp watch files and start BrowserSync
gulp build executes following tasks: cleanUp, favicon, font, img, js, jsLint, json, scss, scssLint, svg
gulp lintAll executes following tasks: jsLint, scssLint
gulp cleanUp clean up public folder
gulp favicon generate favicons
gulp font copy font files
gulp img copy and compress images
gulp js uglify, minify and concat js files
gulp jsLint checks js follows lint rules
gulp json copy and minify json files
gulp scss compile, minify and concat scss files
gulp scssLint checks scss follows lint rules
gulp svg copy and compress svg files
gulp watch watch scss, js, json, img, font and svg files

gulpfile.json

Description
browserSyncConfig Required - Defines which config is used for BrowserSync (default: browserSyncDocker)
sourcePath Required - Path to raw files (default: gulpfiles/)
publicPath Required - Path to transpiled files (default: public/)
env Required - Environment dev, test or prod (default: prod)

Path generation with Locale code and Generic locale code

  • Mode 1 - example.com/de/ = 'process' => \App\Utility\LanguageUtility::LOCALE_URL | \App\Utility\LanguageUtility::DOMAIN_DISABLED,
  • Mode 2 - example.de = 'process' => \App\Utility\LanguageUtility::LOCALE_URL | \App\Utility\LanguageUtility::DOMAIN_ENABLED,
  • Mode 3 - example.com (de-DE session) = 'process' => \App\Utility\LanguageUtility::LOCALE_SESSION | \App\Utility\LanguageUtility::DOMAIN_DISABLED, (default)

It depends on your configuration what will be returned.

Mode 1 Mode 2 Mode 3
locale code de-DE de-DE xx-XX
generic locale code de-DE xx-XX xx-XX
Twig PHP Twig Example PHP Example
locale code {{ lc }} LanguageUtility::getLocale() {{ path_for('user-register-' ~ lc) }} $this->router->pathFor('user-register-' . LanguageUtility::getLocale())
generic locale code {{ glc }} LanguageUtility::getGenericLocale() {{ path_for('user-login-' ~ glc) }} $this->router->pathFor('user-login-' . LanguageUtility::getGenericLocale())

How to create further localisations

  • Duplicate one existing file in folder locale/ (e.g. copy de-DE.php to fr-FR.php)
  • (if you use Mode 1 or 2) Duplicate one existing file in folder config/routes/ (e.g. copy de-DE.php to fr-FR.php)
  • (if you use Mode 1 or 2) Change route prefix from /de/ to /fr/ in config/routes/fr-FR.php
  • You can also define paths like /fr-be/ (locale/fr-BE.php/ config/routes/fr-BE.php) for example
  • If you want to show language in langswitch, add fr-FR and domain in locale => active (config/additional-settings.php)
  • (if you use Mode 1 or 2) Add case for fr/ in src/localisation.php

How to switch between different url modes

Mode 1

Example: example.com/de/

Mode 2

Example: de.example.com or example.de

Mode 3 (default)

Example: example.com

ACL settings

With Geggleto ACL, routes are protected by role the current user has. By default every new route is not accessable until you give the route roles. Routes are defined in the route files (e.g. config/routes/de-DE.php). Any other resource is defined in config/settings.php. Inside the Twig templates you can use ACL functions has_role and is_allowed. Inside controllers you can also use this ACL functions and many more (e.g. isAllowed()).

Troubleshooting

In some cases you'll get the error message "Internal Server Error".

If this happened, go to public/.htaccess and enable RewriteBase /.

If project is in sub directory then RewriteBase /project/public/.

Links