Schritt 1: Laravel-Installation und Einrichtung
Navigiere in das neu erstellte Laravel-Projektverzeichnis
composer create-project --prefer-dist laravel/laravel laravel-api
Konfiguriere die Datenbankverbindung in der .env-Datei:
cd laravel-api
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
Schritt 2: Erstellen der API-Routen
Route::get('/posts', 'PostController@index');
Route::get('/posts/{id}', 'PostController@show');
Schritt 3: Controller erstellen
php artisan make:controller PostController
Schritt 4: Datenbankmigrationen und Modelle
php artisan make:migration create_posts_table
Erstelle ein Eloquent-Modell für deine Datenbanktabelle, wenn du noch keines hast:
php artisan migrate
php artisan make:model Post
Kommentare 0
Noch keine Kommentare. Seien Sie der Erste!