Laravel: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Links) |
|||
Zeile 12: | Zeile 12: | ||
composer require laravel/ui | composer require laravel/ui | ||
composer require spatie/laravel-permission | composer require spatie/laravel-permission | ||
composer require blade-ui-kit/blade-icons | #composer require blade-ui-kit/blade-icons | ||
php artisan ui bootstrap --auth | php artisan ui bootstrap --auth | ||
dbtool create-db-and-user lrv$PROJ $PROJ "$PASSW" | dbtool create-db-and-user lrv$PROJ $PROJ "$PASSW" |
Version vom 14. November 2023, 14:47 Uhr
Links
Projekt einrichten
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=$PASSWD/" .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
Bootstrap 5
- app\Providers\AppServiceProvider.php
use Illuminate\Pagination\Paginator;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Paginator::useBootstrapFive();
}
Install Laravel-Breeze (Authentification)
composer require laravel/breeze --dev
php artisan breeze:install blade
php artisan migrate
Projekt aktualisieren
npm install
npm run dev
Artisan Kommandos
make:controller
php artisan make:controller RoleController --invokable
- app/Http/Controllers/RoleController
class RoleController extends Controller{ public function __invoke(Request $request){} }
- web.php:
Route::post('/role', RoleController::class);
php artisan make:controller RoleController --resource Erzeugt eine Date
- app/Http/Controllers/RoleController
class RoleController extends Controller{ public function index(){} public function create(){} public function store(Request $request){} public function show(string $id){} public function edit(string $id){} public function update(Request $request, string $id){} public function destroy(string $id){} }
make:view
php artisan make:view role.index
- resources/views/role/index.blade.php
<div> <!-- ... --> </div>
Sonstige
php artisan make:seeder PermissionSeeder
php artisan migrate:fresh --seed
php artisan make:controller RoleController --resource
php artisan make:request StoreRoleRequest
php artisan make:view users.index
Integrierter Webserver
php artisan serve
I18N
- config/app.php
'locale' => 'de_DE', 'available_locales' => [ 'English' => 'en', 'German' => 'de_DE', ],
- resources/lang/de_DE.json
{ "Cancel": "Abbrechen", "OK": "OK", "Save": "Speichern" }