This command will create
Posted: Sun Dec 22, 2024 9:07 am
It works with single-page applications (such as Vue, Angular, and React) and supports mobile app authentication. Prerequisites To complete this tutorial you will need the following: Knowledge about Laravel . Basic knowledge of using an HTTP client such as Insomnia . As you can see, Laravel Sanctum does much more. However, in this tutorial, we will use it to create APIs. To start up Let’s start by creating a new Laravel application. To do this, let’s run the command below in our terminal: Bash Copy the code composer create-project --prefer-dist laravel/laravel laravel_sanctum Here, laravel_sanctum is the name of the application.
This command will create a new folder named laravel_sanctum containing our Laravel application. This is a great time to start the Laravel application to make sure everything is working as expected: Bash Copy the code cd laravel_sanctum php artisan serve Installation and configuration Once the Laravel application is in place, let's add Laravel Sanctum to it. First, we telegram philippines girl need to install Laravel Sanctum into our application using Composer: Bash Copy the code composer require laravel/sanctum Next, we will publish the Laravel Sanctum configuration and migration files using the following command: Bash Copy the code php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" We then create a sanctum.
php file in the config directory , as well as the necessary migration files in the migrations directory . Before running the migrations, the database must be configured. Create a database.sqlite file : Bash Copy the code touch database/database.sqlite NOTE : Windows users will not be able to use the "touch" command, so use your IDE to generate the file if needed. Then update the .env file as follows: Powershell Copy the code DB_CONNECTION=sqlite DB_DATABASE=/absolute/path/to/database.sqlite Now run the database migrations: Bash Copy the code php artisan migrate In addition to the tables provided with a default Laravel, this command creates a table personal_access_tokens (personal access token) in the database where all tokens will be stored.
This command will create a new folder named laravel_sanctum containing our Laravel application. This is a great time to start the Laravel application to make sure everything is working as expected: Bash Copy the code cd laravel_sanctum php artisan serve Installation and configuration Once the Laravel application is in place, let's add Laravel Sanctum to it. First, we telegram philippines girl need to install Laravel Sanctum into our application using Composer: Bash Copy the code composer require laravel/sanctum Next, we will publish the Laravel Sanctum configuration and migration files using the following command: Bash Copy the code php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" We then create a sanctum.
php file in the config directory , as well as the necessary migration files in the migrations directory . Before running the migrations, the database must be configured. Create a database.sqlite file : Bash Copy the code touch database/database.sqlite NOTE : Windows users will not be able to use the "touch" command, so use your IDE to generate the file if needed. Then update the .env file as follows: Powershell Copy the code DB_CONNECTION=sqlite DB_DATABASE=/absolute/path/to/database.sqlite Now run the database migrations: Bash Copy the code php artisan migrate In addition to the tables provided with a default Laravel, this command creates a table personal_access_tokens (personal access token) in the database where all tokens will be stored.