Langutor

Aus Vokabulabor
Zur Navigation springen Zur Suche springen

Links

Zielsetzung

Das Projekt Langutor beinhaltet eine Webseite, generiert mit dem Framework Laravel.

Namensgebung

Ein Kunstwort aus Language und Tutor.

Einrichtung

Installation Laravel + npm

apt install php-laravel-framework npm

Einrichten Projekt

PROJ=langutor
PASSW=topsecret
BASE=/home/ws/php/$PROJ
cd $(dirname $BASE)
composer create-project laravel/laravel $PROJ
cd $BASE
sudo apt install php-intl
composer require laravel/ui
composer require spatie/laravel-permission
#composer require blade-ui-kit/blade-icons
php artisan ui bootstrap --auth
dbtool create-db-and-user lrv$PROJ $PROJ "$PASSW"
sed -i -e "s/DB_DATABASE=.*/DB_DATABASE=lrv$PROJ/" \
  -e "s/DB_USERNAME=.*/DB_USERNAME=$PROJ/" \
  -e "s/DB_PASSWORD=.*/DB_PASSWORD=$PASSW/" .env
M_HOST=mail.gmx.net
M_PORT=587
M_USER=example@gmx.de
M_PW=Top.Secret42
sed -i -e "s/MAIL_MAILER=.*/MAIL_MAILER=smtp/" \
  -e "s/MAIL_HOST=.*/MAIL_HOST=$M_HOST/" \
  -e "s/MAIL_PORT=.*/MAIL_PORT=$M_PORT/" \
  -e "s/MAIL_USERNAME=.*/MAIL_USERNAME=$M_USER/" \
  -e "s/MAIL_PASSWORD=.*/MAIL_PASSWORD=$M_PW/" \
  -e "s/MAIL_ENCRYPTION=.*/MAIL_ENCRYPTION=STARTTLS/" \
  -e "s/MAIL_FROM_ADDRESS=.*/MAIL_FROM_ADDRESS=\"$M_USER\"/" .env
php artisan migrate
npm install
npm run dev

Bootstrap 5

  • app\Providers\AppServiceProvider.php
use Illuminate\Pagination\Paginator;
/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Paginator::useBootstrapFive();
}

Einbinden laraknife

  • Einbinden eines lokalen Packages
  • composer.json
"repositories": [
    {
        "type": "path",
        "url": "../laraknife",
        "options": {
            "symlink": true
        }
    }
],
...
"minimum-stability": "dev",
composer require hamatoma/laraknife
vendor/hamatoma/laraknife/scripts/laraknife-tool.sh build-links
composer dump-autoload
mkdir -p resources/lang
ln -s ../../../laraknife/resources/lang/de_DE.json resources/lang
  • routes/web.php
SPropertyController::routes();
UserController::routes();
  • /resources/views/home.blade.php
SPropertyController::routes();
UserController::routes();
  • config/app.php
    'locale' => 'de_DE',
    'available_locales' => [
        'English' => 'en',
        'German' => 'de_DE',
      ],

NGINX-Konfiguration

  • /etc/nginx/sites-available/langutor.test
server {
    listen 80;
    listen [::]:80;
    server_name langutor.test;
    root /home/ws/php/langutor/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}