There is no license information available for the latest version (dev-main) of this package.

Flexible user registration and authentication module for Yii3


README

68747470733a2f2f6c68332e676f6f676c6575736572636f6e74656e742e636f6d2f65685354506e5871726b6b304d33552d5550436a4330667479394b366c67796b4b32574f5541326e5548703867496b526a65544e387a385341426c6b766376522d39504972626f7849765047756a50675765624c51654848675837794c556f7846536475695a72546f6736576f5a4c694176716354523151545056526d6e733274596a414370703745513d7732343030

Flexible user registration and authentication module for Yii3.


Total Downloads bulma boostrap5 tailwind codecov

Directory structure

  config/             contains application configurations
  messages            contains translations for all languages
  src/                application directory
      Action          contains action controller classes
      ActiveRecord    contains active record classes
      Form            contains form classes
      Helper          contains helper classes
      Middleware      contains class middleware
      Migration       contains migration classes
      Repository      contains repository classes
      Service         contains service classes

Project

In this link you will find the lists of tasks to implement: task-list

Installation

Yiisoft application template yiisoft/app

composer create-project --prefer-dist --stability=dev yiisoft/app <your project>

Bootstrap5 css framework

cd <your project>
composer require yii-extension/user:@dev yii-extension/user-view-bootstrap5:@dev
composer require yii-extension/asset-bootstrap5:1.0.x 

Bulma css framework

cd <your project>
composer require yii-extension/user:@dev yii-extension/user-view-bulma:@dev
composer require yii-extension/asset-bulma:1.0.x

Tailwind css framework

cd <your project>
composer require yii-extension/user:@dev yii-extension/user-view-tailwind:@dev
composer require yii-extension/yii-extension/asset-tailwind:1.0.x

Install your driver for the database, for example sqlite

cd <your project>
composer require yiisoft/db-sqlite:3.0.x

Setup configuration

Add authentication configuration to your application config file: config/web/auth.php

<?php

declare(strict_types=1);

use Yiisoft\Definitions\Reference;
use Yiisoft\Session\SessionInterface;
use Yiisoft\User\CurrentUser;

return [
    CurrentUser::class => [
        'withSession()' => [Reference::to(SessionInterface::class)],
        'reset' => function () {
            $this->clear();
        },
    ],
];

Add connection configuration to your application config file: config/common/db.php

<?php

declare(strict_types=1);

use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Sqlite\Connection;

return [
    ConnectionInterface::class => [
        'class' => Connection::class,
        '__construct()' => [
            'dsn' => 'sqlite:'. 'Your dsn',
        ],
    ],
];

Add configuration assets to your application config file: src/Asset/AppAsset.php, for example Bootstrap5:

<?php

declare(strict_types=1);

namespace App\Asset;

use Yii\Extension\Asset\Bootstrap5\Bootstrap5Asset;
use Yiisoft\Assets\AssetBundle;

final class AppAsset extends AssetBundle
{
    public ?string $basePath = '@assets';
    public ?string $baseUrl = '@assetsUrl';
    public ?string $sourcePath = '@resources/assets/css';

    public array $css = [
        'site.css',
    ];

    public array $depends = [
        Bootstrap5Asset::class,
    ];
}

Run command console

./yii

Run migration

Application template:

./yii migrate/up

Using PHP built-in server

php -S 127.0.0.1:8080 -t public

Wait till it is up, then open the following URL in your browser

http://localhost:8080

Includes the following features:

  • User module:
    • [/login] - Display login form.
    • [/logout] - Log the user out.
    • [/confirm[/{id}/{token}]] - Confirms a user (requires id and token query params).
    • [/profile] - Displays profile form.
    • [/register] - Displays registration form.
    • [/request] - Displays recovery request form.
    • [/resend] - Displays resend form.
    • [/reset[/{id}/{token}]] - Displays password reset form (requires id and token query params).
    • [/email/change] - Displays email change form.
    • [/email/attempt[/{id}/{token}]] - Confirm email change (requires id and token query params).

Note: check the directory /runtime/mail, the emails are stored in it.

Codeception testing

The package is tested with Codeception. To run tests:

php -S 127.0.0.1:8080 -t tests/_data/public > /dev/null 2>&1&
vendor/bin/codecept run Unit,Acceptance,Functional

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

/vendor/bin/psalm

Quality of code

Codacy Badge static analysis type-coverage

License

The yii-extension/user is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Extension.

Support the project

Open Collective

Powered by Yii Framework

Official website