Laravel: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 59: | Zeile 59: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Artisan | = Artisan Kommandos = | ||
== make:controller == | |||
<pre>php artisan make:controller RoleController --invokable | |||
</pre> | |||
* app/Http/Controllers/RoleController | |||
<pre> | |||
class RoleController extends Controller{ | |||
public function __invoke(Request $request){} | |||
} | |||
</pre> | |||
<pre> | |||
php artisan make:controller RoleController --resource | |||
Erzeugt eine Date | |||
</pre> | |||
* app/Http/Controllers/RoleController | |||
<pre> | |||
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){} | |||
} | |||
</pre> | |||
== make:view == | |||
<pre> | |||
php artisan make:view role.index | |||
</pre> | |||
* resources/views/role/index.blade.php | |||
<pre> | |||
<div> | |||
<!-- ... --> | |||
</div> | |||
</pre> | |||
== Sonstige == | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
php artisan make:seeder PermissionSeeder | php artisan make:seeder PermissionSeeder |
Version vom 7. November 2023, 19:44 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){} }
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