Author: Smin Rana

  • Laravel Sanctum Tutorial Step by Step

    Laravel Sanctum Tutorial Step by Step

    Laravel Sanctum provides a featherweight authentication system for single-page applications, mobile applications, and simple, token-based APIs. Sanctum allows each user of your application to generate multiple API tokens for their account. These tokens may be granted abilities/scopes which specify which actions the tokens are allowed to perform.

    Installation

    composer require laravel/sanctum and composer update

    Next, you should publish the Sanctum configuration and migration files using the vendor:publish Artisan command. 

    php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
    php artisan migrate 

    You can also use following sql for creating table, if there is a problem to run migrate command.

    CREATE TABLE `personal_access_tokens` (
       `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
       `tokenable_type` varchar(255) NOT NULL,
       `tokenable_id` bigint(20) unsigned NOT NULL,
       `name` varchar(255) NOT NULL,
       `token` varchar(64) NOT NULL,
       `abilities` text DEFAULT NULL,
       `last_used_at` timestamp NULL DEFAULT NULL,
       `created_at` timestamp NULL DEFAULT NULL,
       `updated_at` timestamp NULL DEFAULT NULL,
       PRIMARY KEY (`id`),
       UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
       KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
     ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8

    Next, if you plan to utilize Sanctum to authenticate an SPA, you should add Sanctum’s middleware to your api middleware group within your application’s app/Http/Kernel.php file:

    'api' => [
                'throttle:60,1',
                'bindings',
                \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
            ],
    Laravel Sanctum Tutorial Step by Step

    Download source code

    Spread the love
  • Install flutter mac by brew

    Flutter got easier to install on any Mac, just install it by home brew. It will install both flutter and dart.

    brew install flutter

    Check version of Flutter

    flutter --version

    Check version of Dart

    dart --version

    Spread the love
  • Bitnami WordPress redirect www to non-www

    I’m a big fan of Amazon Lightsail, I find it better than others for WordPress sites. Recently I was trying to redirect one of my WordPress websites, www traffic to non-www by updating .htaccess file but nothing was working.

    After reading the Bitnami doc I found in Bitnami WordPress it handles differently.

    Edit httpd-prefix.conf by vim or nano

    vim /opt/bitnami/apps/wordpress/conf/httpd-prefix.conf
    RewriteCond "%{HTTP_HOST}" ^www.flutterframework.com$
    RewriteRule "^/?(.*)" "%{REQUEST_SCHEME}://flutterframework.com/$1" [L,R=302,NE]

    restart apache:

    sudo /opt/bitnami/ctlscript.sh restart apache

    Everything should work.

    Watch the video

    https://www.youtube.com/watch?v=k0kJcThlkeM
    Spread the love