Langutor: Unterschied zwischen den Versionen

Aus Vokabulabor
Zur Navigation springen Zur Suche springen
Zeile 19: Zeile 19:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
PROJ=langutor
PROJ=langutor
PASSW=topsecret
BASE=/home/ws/php/$PROJ
BASE=/home/ws/php/$PROJ
cd $(basename $BASE)
cd $(basename $BASE)
Zeile 24: Zeile 25:
cd $BASE
cd $BASE
composer require laravel/ui
composer require laravel/ui
composer require spatie/laravel-permission
#composer require blade-ui-kit/blade-icons
php artisan ui bootstrap --auth
php artisan ui bootstrap --auth
dbtool create-db-and-user app$PROJ $PROJ topsecret
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</pre>
 
php artisan migrate
npm install
npm run dev
</syntaxhighlight>
</syntaxhighlight>
* Anpassungen in .env
 
 
== Bootstrap 5 ==
* app\Providers\AppServiceProvider.php
<syntaxhighlight lang="php">
use Illuminate\Pagination\Paginator;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
    Paginator::useBootstrapFive();
}
</syntaxhighlight>
 
== Einbinden laraknife ==
* Einbinden eines lokalen Packages
* composer.json
<pre>
<pre>
"repositories": [
    {
        "type": "path",
        "url": "../laraknife",
        "options": {
            "symlink": true
        }
    }
],
...
...
APP_URL=http://langutor.test
"minimum-stability": "dev",
...
</pre>
DB_DATABASE=applangutor
<pre>
DB_USERNAME=langutor
composer require hamatoma/laraknife
DB_PASSWORD=topsecret
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
</pre>
* routes/web.php
<pre>
SPropertyController::routes();
UserController::routes();
</pre>
* /resources/views/home.blade.php
<pre>
SPropertyController::routes();
UserController::routes();
</pre>
</pre>
<syntaxhighlight lang="bash">
npm install
npm run dev
</syntaxhighlight>
== NGINX-Konfiguration ==
== NGINX-Konfiguration ==
* /etc/nginx/sites-available/langutor.test
* /etc/nginx/sites-available/langutor.test

Version vom 14. November 2023, 16:08 Uhr

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 $(basename $BASE)
composer create-project laravel/laravel $PROJ
cd $BASE
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</pre>

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();

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;
    }
}