Open der1der1 opened 3 months ago
laravel new [project name]
*would be wait for a long time!!
php artisan install:api
One new database migration has been published. Would you like to run all pending database migrations? (yes/no) [yes]: #""YES"" !!
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
* After manually created a table.php (it contains sql command) * plz delete all the other table.php (such as ~tocken.php) ```php php artisan migrate
get in Model/user.php and add follwing:
use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable{ use HasApiTokens, HasFactory, Notifiable; }
get in routes/api.php and add follwing:
Route::group(['middleware' => ['auth:sanctum']], function () { });
found Model, Migration, & Controller
php artisan make:model [project name] -rmc
routes setting, get in routes/api.php and add follwing:
use App\Http\Controllers\[controller name];
Route::apiResource('[project name]s', [controller name]::class);
* [project name] such as: Animal. * [controller name] such as [AnimalController] 9. testing route. ```php php artisan route:list
it would show lots of infos being like:
GET|HEAD / ........................................................ GET|HEAD api/animal ......... animal.index › AnimalController@index POST api/animal ......... animal.store › AnimalController@store GET|HEAD api/animal/{animal} .. animal.show › AnimalController@show PUT|PATCH api/animal/{animal} animal.update › AnimalController@upda… DELETE api/animal/{animal} animal.destroy › AnimalController@des… GET|HEAD api/user ................................................. GET|HEAD sanctum/csrf-cookie sanctum.csrf-cookie › Laravel\Sanctum… GET|HEAD up .......................................................
10.
php artisan serve
*would be wait for a long time!!
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
get in Model/user.php and add follwing:
get in routes/api.php and add follwing:
found Model, Migration, & Controller
routes setting, get in routes/api.php and add follwing:
Route::apiResource('[project name]s', [controller name]::class);
it would show lots of infos being like:
10.